标签:ace out space blog iostream using coder cout names
思路:
递归,分治。
实现:
1 #include <iostream> 2 #include <cstdio> 3 using namespace std; 4 5 int dfs(int x) 6 { 7 if (x <= 1) 8 return 1; 9 if (x & 1) 10 return dfs((x - 1) >> 1); 11 return dfs(x >> 1) + dfs((x - 2) >> 1); 12 } 13 14 int main() 15 { 16 int n; 17 cin >> n; 18 cout << dfs(n) << endl; 19 return 0; 20 }
标签:ace out space blog iostream using coder cout names
原文地址:http://www.cnblogs.com/wangyiming/p/6655478.html