CF——#150div2B
来源:互联网 发布:黑马程序员有用吗 编辑:程序博客网 时间:2024/04/28 23:55
题目地址:http://codeforces.com/contest/244/problem/B
解析:深搜下就可以了。
#include <iostream>#include <cstring>typedef long long ll;using namespace std;#define N 1005ll ans;int flag[15];ll n;int check(int x){int temp;int countt=0;memset(flag,0,sizeof(flag));while(x){temp=x%10;if(!flag[temp]) countt++;flag[temp]++;if(countt>2) return 0;x/=10;}return 1;}void dfs(ll x){int i;if(x>n) return ;if(check(x)){ ++ans; if(x==0) i=1; else i=0; for(i;i<10;i++) dfs(x*10+i);}}int main(){ while(cin>>n) { if(n<=10) cout<<n<<endl; else { ans=0; dfs(0); cout<<ans-1<<endl; //减去0. } } return 0;}
- CF——#150div2B
- CF——#182div2B
- 水题——codeforces#275div2B
- (贪心)Color the Fence - CF 202 Div2B
- 【CF】【318div2B】【暴力枚举】【度的应用】
- CF——Trace
- CF——Taxi
- CF—Hot Bath
- cf——#30A
- CF——#23C
- CF——#182div2C
- CF——Average Numbers
- cf——B. Garland
- CF——Next Round
- CF——Game Outcome
- CF —— IQ Test
- CF——Dishonest Sellers
- Codeforces R278 div2B 分类讨论
- 写在第一份工作离职的夜晚
- epub学习
- HDU 4679 Terrorist’s destroy 解题报告
- 记录 留给 某时的我
- JAVA垃圾收集器
- CF——#150div2B
- 安卓 创建一个选项菜单的方法和步骤:
- 设计继承树1
- 12个有趣的C语言问答
- 重建二叉树
- 编程之美-不要被阶乘吓到
- JavaScript 教程
- HTML DOM 教程
- LeetCode-Convert Sorted List to Binary Search Tree