当前位置:网站首页>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;
}
边栏推荐
- 字节也开始缩招了...
- Altium designer software commonly used the most complete package library, including schematic library, PCB library and 3D model library
- Quectel EC20 4G module dial related
- The JVM thread state
- 高项 04 项目变更管理
- Zero shift of leetcode
- ByteDance Interview Questions: Mirror Binary Tree 2020
- P7阿里面试题2020.07 之滑动窗算法(阿里云面试)
- 物理层课后作业
- Fragments
猜你喜欢
随机推荐
MUI无法滚动?完美解决
详解C语言中的wait()函数和waitpid()函数
高项 03 项目立项管理
如何 认识与学习BASH
SIGINT, SIGKILL, SIGTERM signal difference, summary of various signals
sklearn数据预处理
db.sqlite3 has no "as Data Source" workaround
常用测试用例设计方法之正交实验法详解
力扣 636. 函数的独占时间
TCP段重组PDU
codeforces Valera and Elections (这思维题是做不明白了)
DSP+ARM+FPGA高速PCIE/千兆网口信号仿真介绍
Rsync常见错误
Service
Better Scroll Y上下滚动无法上拉滚动解决办法
事务总结
imageio读取.exr报错 ValueError: Could not find a backend to open `xxx.exr‘ with iomode `r`
长沙学院2022暑假训练赛(一)六级阅读
crc计算
6 states of a thread