当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
分布式事务产生的原因
jvm线程状态
Output method of list string print(*a) print(““.join(str(c) for c in a) )
2022-08-08: Given an array arr, it represents the height of the missiles that will appear in order from morning to night.When the cannon shoots missiles, once the cannon is set to shoot at a certain h
按图搜索1688商品接口(item_search_img-按图搜索1688商品(拍立淘接口)代码对接教程
变压器的工作原理(图解,原理图讲解,一看就懂)
排序第一节——插入排序(直接插入排序+希尔排序)(视频讲解26分钟)
6 states of a thread
虚拟机网卡报错:Bringing up interface eth0: Error: No suitable device found: no device found for connection
学习小笔记---机器学习
随机推荐
SIGINT,SIGKILL,SIGTERM信号区别,各类信号总结
学习小笔记---机器学习
vim 程序编辑器的基本操作(积累)
MongDb query method
默默重新开始,第一页也是新的一页
shardingsphere data sharding configuration item description and example
Better Scroll Y上下滚动无法上拉滚动解决办法
sklearn数据预处理
vlucas/phpdotenv phpdotenv获取变量内容偶尔出现返回false
半导体新能源智能装备整机软件系统方案设计
Built-in macros in C language (define log macros)
物理层课后作业
INSTALL_RPATH and BUILD_RPATH problem in CMake
MySQL高级特性之分布式(XA)事务的介绍
买口罩(0-1背包)
2022-08-08: Given an array arr, it represents the height of the missiles that will appear in order from morning to night.When the cannon shoots missiles, once the cannon is set to shoot at a certain h
排序第二节——选择排序(选择排序+堆排序)(两个视频讲解)
crc计算
e-learning summary
AD的library中 库文件后缀有.intlib .schlib .pcblib 的区别