hihocoder #1331 : 扩展二进制数

#1331 : 扩展二进制数 

题目链接: 点击打开链接
思路:从第一位开始推,奇数个第一位就是1,偶数个第一个就是0或2,然后往下推即可
代码:
#include
using namespace std;
int  get(int x)
{
	if(x==0||x==1) return 1;
	if(x%2)
	{
		return get(x/2);
	}
	else
	{
		return get(x/2)+get((x-2)/2);
	}
}
int main()
{
	int n;
	while(cin>>n)
	{
		cout<

你可能感兴趣的:(dp)