codeforces 9C
来源:互联网 发布:博威电力软件 编辑:程序博客网 时间:2024/06/05 15:42
题目大意:给出数n(1<=n<=10^9),求不超过n,只由0、1构成的数的个数。
分析:
1位数:1
2位数:10、11
3位数:100、101、110、111
……
即有:
k位数:a、b
k+1位数:a*10,a*10+1,b*10,b*10+1。
#include<bits/stdc++.h>using namespace std;int ans=0;void get(int x,int n){ if(x>n) return; ++ans; get(10*x,n); get(10*x+1,n);}int main(){ int n; cin>>n; get(1,n); cout<<ans<<endl; return 0;}
0 0
- codeforces 9C
- Codeforces-340-C(c++)
- Codeforces-507-C(c++)
- CodeForces 731C C
- CodeForces-612C C
- codeforces 9C. Hexadecimal's Numbers
- CodeForces 9C - Hexadecimal's Numbers
- Codeforces 9C Hexadecimal's Numbers
- Codeforces-9C-Hexadecimal's Numbers
- codeforces 9C 数位DP做法
- CodeForces 9C-Hexadecimal's Numbers-构造
- CodeForces 9C Hexadecimal's Numbers
- Codeforces 9C Hexadecimal‘s number (DFS)
- codeforces 9C Hexadecimal's Numbers
- CODEFORCES 265C CODEFORCES, 265C
- codeforces #78 div2 C
- Codeforces 117C Cycle
- CodeForces 209C
- Unity 实现模拟按键
- C++ 多态与虚函数
- zoj 3506 Cut the Tree (树形dp)
- Bootstrap-组件-3
- 随web容器启动Java类,spring初始化某个类的方法
- codeforces 9C
- TCP -- 传输控制协议
- AngularJS学习笔记(2)
- Hibernate之关系映射(二)
- ios 字符串拼接 字符串拼装 NSString连接
- Google Guava的5个鲜为人知的特性
- C++ 多继承与虚基类
- 关于流和缓冲区的理解
- MATLAB常用命令(二)之 多项式运算