当前位置:网站首页>Codeforces Round #359 (Div. 2) C. Robbers' watch 暴力枚举
Codeforces Round #359 (Div. 2) C. Robbers' watch 暴力枚举
2022-08-09 07:01:00 【swust_fang】
题目链接
题意是真的烦,到最后才知道是n个m其实就是限定表的两个时区的位数,所以所当数不够填满时区的时候前边自动补零
思路:首先来说不能有重复的数字的话,小时和分钟的总位数大于7肯定不行。
7的7次方也才823543
所以说我们从把i从0枚举到n,j从0枚举到m即可。为什么复杂度是正确的?
其实就是考虑LenN+LenM<=7且n*m的最大是的多少(Len表示位数有多少)
考虑两个极限N1位,M6位,最大7*7^6 刚刚好7的7次方
N4位,M3位,最大7^3*7^4还是7^7,小于1e6的复杂度
//#pragma comment (linker, "/STACK:102400000,102400000")
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<string>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<stack>
#include<vector>
#include<map>
#include<queue>
#include<list>
#include<time.h>
#define myself i,l,r
#define lson i<<1
#define rson i<<1|1
#define Lson i<<1,l,mid
#define Rson i<<1|1,mid+1,r
#define half (l+r)/2
#define lowbit(x) x&(-x)
#define min4(a, b, c, d) min(min(a,b),min(c,d))
#define min3(x, y, z) min(min(x,y),z)
#define max3(x, y, z) max(max(x,y),z)
#define max4(a, b, c, d) max(max(a,b),max(c,d))
//freopen("E://1.in","r",stdin);
//freopen("E://1.out","w",stdout);
typedef unsigned long long ull;
typedef long long ll;
#define pii make_pair
#define pr pair<int,int>
const int inff = 0x3f3f3f3f;
const int dir[4][2] = {0, 1, 0, -1, 1, 0, -1, 0};
const int mdir[8][2] = {0, 1, 0, -1, 1, 0, -1, 0, 1, 1, -1, 1, 1, -1, -1, -1};
const double eps = 1e-10;
const double PI = acos(-1.0);
const double E = 2.718281828459;
using namespace std;
const long long inFF = 9223372036854775807;
const int mod=1e9+7;
const int maxn=1e5+5;
int a[7];
int len1,len2;
int cal(ll x)
{
x--;
if(x==0) return 1;
int ans=0;
while(x){x/=7;ans++;}
return ans;
}
bool check(int x,int y)
{
int cnt=0;
memset(a,0,sizeof(a));
while(x){a[x%7]++;x/=7;cnt++;}
a[0]+=len1-cnt;
cnt=0;
while(y){a[y%7]++;y/=7;cnt++;}
a[0]+=len2-cnt;
for(int i=0;i<=6;i++)
if(a[i]>=2)
return 0;
return 1;
}
int main()
{
ll n,m;
cin>>n>>m;
len1=cal(n),len2=cal(m);
if(len1+len2>7)
{
cout<<0<<endl;
return 0;
}
ll ans=0;
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
if(check(i,j)) ans++;
cout<<ans<<endl;
}
边栏推荐
- P6阿里机试题之2020 斐波那契数
- 【nuxt】服务器部署步骤
- SIGINT,SIGKILL,SIGTERM信号区别,各类信号总结
- mysql summary
- Import the pycharm environment package into another environment
- 【MySQL】update mysql.user set authentication_string=password(“123456“) where User=‘root‘; 报错
- 字节跳动面试题之镜像二叉树2020
- MongDb query method
- 排序第四节——归并排序(附有自己的视频讲解)
- 图论,二叉树,dfs,bfs,dp,最短路专题
猜你喜欢
longest substring without repeating characters
【报错】Root Cause com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
虚拟机网卡报错:Bringing up interface eth0: Error: No suitable device found: no device found for connection
高项 03 项目立项管理
Variable used in lambda expression should be final or effectively final报错解决方案
金九银十即将到来,求职套路多,面试指南我来分享~
6 states of a thread
图论,二叉树,dfs,bfs,dp,最短路专题
Search 1688 product interface by image (item_search_img-search 1688 product by image (Politao interface) code docking tutorial
jvm线程状态
随机推荐
【ROS2原理8】节点到参与者的重映射
买口罩(0-1背包)
way of thinking problem-solving skills
【Docker】Docker安装MySQL
car-price-deeplearning-0411
rsync:recv_generator: mkdir (in backup) failed:Permission denied (13) |failed to set times on '.'
更改Jupyter Notebook默认打开目录
常见的分布式事务解决方案
Altium designer software commonly used the most complete package library, including schematic library, PCB library and 3D model library
P7 Alibaba Interview Questions 2020.07 Sliding Window Algorithm (Alibaba Cloud Interview)
The water problem of leetcode
XxlJobConfig distributed timer task management XxlJob configuration class, replace
crc计算
AD画PCB板教程 20分钟讲清楚操作流程 铺铜 网络标号
高项 03 项目立项管理
dp学习笔记
XxlJobConfig分布式定时器任务管理XxlJob配置类,替代
io.lettuce.core。RedisCommandTimeoutException命令超时
Quectel EC20 4G module dial related
Reverse Engineering