20 1
20 2
代码如下:
#include <iostream> using namespace std; int main() { int n; int c = 1; int m; while (cin>>n) { m = 1; while(1) { if (c <= n) { c = 2 * c; } else { c = (c - n) * 2 - 1; } if ( c == 1) break; m++; } cout<<m<<endl; } return 0; }
原文:http://blog.csdn.net/liuchang54/article/details/43538387