当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
随机推荐
sklearn数据预处理
Reverse Engineering
ByteDance Written Exam 2020 (Douyin E-commerce)
P7 Alibaba Interview Questions 2020.07 Sliding Window Algorithm (Alibaba Cloud Interview)
6 states of a thread
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
P6阿里机试题之2020 斐波那契数
图论,二叉树,dfs,bfs,dp,最短路专题
Variable used in lambda expression should be final or effectively final报错解决方案
浅识微服务架构
Introduction and use of BeautifulSoup4
Import the pycharm environment package into another environment
Service
【转载】Deep Learning(深度学习)学习笔记整理
APP商品详情源数据接口(淘宝/京东/拼多多/苏宁/抖音等平台详情数据分析接口)代码对接教程
The Integer thread safe
VS2019 common shortcut keys
当酷雷曼VR直播遇上视频号,会摩擦出怎样的火花?
2022.8.8DAY628
Altium designer软件常用最全封装库,包含原理图库、PCB库和3D模型库







