CodeForces 686C-Robbers' watch
题意:
一个电子手表的示数是7进制的,现在告诉你一天有多少小时和一小时有多少分钟,问你一天里有多少个时刻,这个表上显示的数字各不相同.
分析:
先找出表上有多少位数字,再按位dfs,看最后得到的数是否<n和<m,把分和时转化为7进制,若位数大于7则直接输出0,若不大于零,则用dfs找到分和时的所有位不相同的情况
代码如下:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <iterator>
#include <vector> using namespace std; #define LL long long
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 10000010
#define MAXM 1000010 #include <iostream>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <ctime>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <iterator>
#include <vector> using namespace std; #define LL long long
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 10000010
#define MAXM 1000010 LL n, m;
int weishu_n, zongweishu_n_m, kinds_ans;
int a[]; int check()
{
int sum , x;
sum = ;
x = ;
for(int i = weishu_n-; i >= ; i--)
{
sum += x*a[i];
x *= ;
}
if(sum >= n)
return ;
sum = ;
x = ;
for(int i = zongweishu_n_m-; i >= weishu_n; i--)
{
sum += x*a[i];
x *= ;
}
if(sum >= m)
return ;
return ;
} void dfs(int cnt)
{
if(cnt == zongweishu_n_m)
{
if(check())
kinds_ans++;
}
else
for(int i = ; i < ; i++ )
{
int ok = ;
for(int j = ; j < cnt; j++ )
if(i == a[j])
{
ok = ;
break;
}
if(ok)
{
a[cnt] = i;
dfs(cnt+);
}
}
} int main()
{
int pos;
int kn, km;
while(scanf("%lld%lld", &n, &m)==)
{
memset(a, , sizeof(a));
kinds_ans = ;
weishu_n = ;
zongweishu_n_m = ;
pos = ;
kn = n-;
if(!kn)
pos++;
while(kn)
{
kn /= ;
pos++;
}
weishu_n = pos;
km = m-;
if(!km)
pos++;
while(km)
{
km /= ;
pos++;
}
zongweishu_n_m = pos;
dfs();
if(zongweishu_n_m > )
printf("0\n");
else
printf("%d\n", kinds_ans);
} return ;
}
CodeForces 686C-Robbers' watch的更多相关文章
- codeforces 686C C. Robbers' watch(dfs)
题目链接: C. Robbers' watch time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Codeforces 658A. Robbers' watch 模拟
A. Robbers' watch time limit per test: 2 seconds memory limit per test: 256 megabytes input: standar ...
- Codeforces Round #359 div2
Problem_A(CodeForces 686A): 题意: \[ 有n个输入, +\space d_i代表冰淇淋数目增加d_i个, -\space d_i表示某个孩纸需要d_i个, 如果你现在手里 ...
- Codeforces Round #359 (Div. 2)C - Robbers' watch
C. Robbers' watch time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- Codeforces Round #359 (Div. 1) A. Robbers' watch 暴力
A. Robbers' watch 题目连接: http://www.codeforces.com/contest/685/problem/A Description Robbers, who att ...
- Codeforces Round #359 (Div. 2) C. Robbers' watch (暴力DFS)
题目链接:http://codeforces.com/problemset/problem/686/C 给你n和m,问你有多少对(a, b) 满足0<=a <n 且 0 <=b &l ...
- codeforces 359 C - Robbers' watch
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description Robb ...
- Codeforces Round #359 (Div. 2) C. Robbers' watch 搜索
题目链接:http://codeforces.com/contest/686/problem/C题目大意:给你两个十进制的数n和m,选一个范围在[0,n)的整数a,选一个范围在[0,m)的整数b,要求 ...
- Codeforces Round #359 (Div. 2) C. Robbers' watch 鸽巢+stl
C. Robbers' watch time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- Robbers' watch CodeForces - 685A (暴力)
大意: 一天n小时, m分钟, 表以7进制显示, 求表显示数字不同的方案数 注意到小时和分钟部分总长不超过7, 可以直接暴力枚举. 关键要特判0, 0的位数要当做1来处理 #include <i ...
随机推荐
- easyui datagrid将表头的checkbox不显示(隐藏)
<script type="text/javascript"> $(function(){ $("#dg").datagrid({ url:&quo ...
- Linux 的字符串截取方法(转)
Linux 的字符串截取很有用.有八种方法. 假设有变量 var=http://www.aaa.com/123.htm. 1. # 号截取,删除左边字符,保留右边字符. echo ${var#*//} ...
- 扩展当easyui datagrid无数据时,显示特定值。如:没有数据
var myview = $.extend({},$.fn.datagrid.defaults.view,{ onAfterRender:function(target){ $.fn.datagrid ...
- 使用ajax登录格式
登录页面: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w ...
- Python多进程编程
转自:Python多进程编程 阅读目录 1. Process 2. Lock 3. Semaphore 4. Event 5. Queue 6. Pipe 7. Pool 序. multiproces ...
- file以及文件大小转化问题
android 获取文件夹.文件的大小 以B.KB.MB.GB 为单位 public class FileSizeUtil { public static final int ...
- Cmap的使用
1.定义 template <class KEY,class ARG_KEY,class VALUE, class ARG_VALUE> class CMap:public CObject ...
- QT笔记之VS开发程序遇到的问题
转载:http://www.cnblogs.com/li-peng/p/3644812.html 转载:http://www.cnblogs.com/csuftzzk/p/VS_Qt_Experien ...
- 18.ssh远程双向无密码登陆
#ssh远程双向无密码登陆 需求:在192.168.10.100执行ssh 192.168.20.205不需要输入密码直接跳转到205机器 #在192.168.10.100执行命令,我这里使用root ...
- 事务码 ListSchema:查看Cube星型结构Schema
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...