Codeforces Round #359 (Div. 2) C. Robbers' watch (暴力DFS)

时间:2022-11-08 07:39:36

题目链接:http://codeforces.com/problemset/problem/686/C

给你n和m,问你有多少对(a, b) 满足0<=a <n 且 0 <=b < m 且a的7进制和n-1的7进制位数相同 且b的7进制和m-1的7进制位数相同,还有a和b的7进制上的每位上的数各不相同。

看懂题目,就很简单了,先判断a和b的7进制位数是否超过7,不超过的话就dfs暴力枚举计算就可以了。

 //#pragma comment(linker, "/STACK:102400000, 102400000")
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef long long LL;
typedef pair <int, int> P;
const int N = 1e5 + ;
int num[], n, m, ans;
bool vis[]; int get(int num[], int len) {
int res = , temp = ;
for(int i = len; i >= ; --i) {
res += num[len] * temp;
temp *= ;
}
return res;
} void dfs(int len1, int len2, int dep) {
if(dep == len1 + len2) {
int sum = , temp = ;
for(int i = len1+len2; i >= len1+; --i) {
sum += temp*num[i];
temp *= ;
}
if(sum < m)
ans++;
return ;
}
else if(dep == len1) {
int sum = , temp = ;
for(int i = len1; i >= ; --i) {
sum += temp*num[i];
temp *= ;
}
if(sum >= n)
return ;
}
dep++;
for(int i = ; i < ; ++i) {
if(vis[i])
continue;
vis[i] = true;
num[dep] = i;
dfs(len1, len2, dep);
vis[i] = false;
} } int main()
{
cin >> n >> m;
int cnt1 = , cnt2 = , temp = n - ;
do {
temp /= ;
++cnt1;
} while(temp);
temp = m - ;
do {
temp /= ;
++cnt2;
} while(temp);
if (cnt1 + cnt2 > ) {
cout << << endl;
} else {
dfs(cnt1, cnt2, );
cout << ans << endl;
}
return ;
}

Codeforces Round #359 (Div. 2) C. Robbers' watch (暴力DFS)的更多相关文章

  1. Codeforces Round &num;359 &lpar;Div&period; 1&rpar; A&period; Robbers&&num;39&semi; watch 暴力

    A. Robbers' watch 题目连接: http://www.codeforces.com/contest/685/problem/A Description Robbers, who att ...

  2. Codeforces Round &num;359 &lpar;Div&period; 2&rpar;C - Robbers&&num;39&semi; watch

    C. Robbers' watch time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  3. Codeforces Round &num;359 &lpar;Div&period; 2&rpar; C&period; Robbers&&num;39&semi; watch 搜索

    题目链接:http://codeforces.com/contest/686/problem/C题目大意:给你两个十进制的数n和m,选一个范围在[0,n)的整数a,选一个范围在[0,m)的整数b,要求 ...

  4. Codeforces Round &num;359 &lpar;Div&period; 2&rpar; C&period; Robbers&&num;39&semi; watch 鸽巢&plus;stl

    C. Robbers' watch time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  5. Codeforces Round &num;359 &lpar;Div&period; 1&rpar; B&period; Kay and Snowflake dfs

    B. Kay and Snowflake 题目连接: http://www.codeforces.com/contest/685/problem/B Description After the pie ...

  6. Codeforces Round &num;359 &lpar;Div&period; 1&rpar;

    A http://codeforces.com/contest/685/standings 题意:给你n和m,找出(a,b)的对数,其中a满足要求:0<=a<n,a的7进制的位数和n-1的 ...

  7. Codeforces Round &num;359 &lpar;Div&period; 2&rpar; B&period; Little Robber Girl&&num;39&semi;s Zoo 水题

    B. Little Robber Girl's Zoo 题目连接: http://www.codeforces.com/contest/686/problem/B Description Little ...

  8. Codeforces Round &num;359 &lpar;Div&period; 2&rpar; A&period; Free Ice Cream 水题

    A. Free Ice Cream 题目连接: http://www.codeforces.com/contest/686/problem/A Description After their adve ...

  9. Codeforces Round &num;359 &lpar;Div&period; 2&rpar; C

    C. Robbers' watch time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

随机推荐

  1. asp&period;net前台代码中引入namespace的方法

    <%@ import NameSpace="System.Data.OleDb" %>

  2. for循环与for循环嵌套

    今天温习了下分支语句跟for循环,主要讲解了for循环嵌套,这里开始有点迷糊了,整理下思路在做练习 for循环嵌套用我自己的大白话来说就是一个外圈的for程序里面一个套着一个小的for程序,如果在范围 ...

  3. Kafka Producer相关代码分析【转】

    来源:https://www.zybuluo.com/jewes/note/63925 @jewes 2015-01-17 20:36 字数 1967 阅读 1093 Kafka Producer相关 ...

  4. 使用Apache Bench进行压力测试

    Apache Bench是Apache中自带的压力测试工具 在linux中我们安装好apache后可以通过ab指令使用它 格式:ab [参数] [http://]ip地址/path/ 常用参数说明: ...

  5. html object元素

    知道object是播放音频,但是想了解具体点,百度一下,感觉模模糊糊的,感觉看不大明白,最后找到一个解释比较详细,先从应用,到解释具体属性, 具体网址是: http://www.w3school.co ...

  6. 四张图揭秘中国AI人才现状

    本文数据来源:领英<全球AI领域人才报告> 最近有非常多的同学看了之前我们的一些文章和直播之后,多对AI领域跃跃欲试,本文我们结合一份人才报告(我个人感觉这份报告还是比较靠谱的),为大家揭 ...

  7. 20175324 2018-2019-2 《Java程序设计》第5周学习总结

    20175324 2018-2019-2 <Java程序设计>第5周学习总结 教材学习内容总结 抽象类和具体类的区别在于抽象类中有抽象方法而具体类中没有.且抽象类不能实例化. 接口:如果一 ...

  8. 上海高校程序设计联赛 D-CSL的字符串 栈模拟

    题目链接:https://ac.nowcoder.com/acm/contest/551/D ASCII码表示的字符转换成整数实测不超过200(具体多少懒得查了) 分析:要求总的字典序最小,那就让最小 ...

  9. React文档(二十二)context

    React中,通过React组件可以很容易地追踪数据流.当你关注一个组件,你可以发现哪一个props被传递了,这样使得你的应用很容被推断. 在一些情况下,你想要传递数据通过组件树而不需要去手动在每一层 ...

  10. 【实战】verilog中&grave;define的使用记录

    背景: 在最近实战开发中发现:对外部芯片进行初始化时,往往需要定义大量参数. 若直接在module中通过localparam或者parameter进行参数定义的话,会带来两个问题: 1.代码长度增加, ...