Pro.ID21623 TitleString Sequence Title链接http://10.20.2.8/oj/exercise/problem?problem_id=21623 AC0 Submit0 Ratio- 时间&空间限制描述Consider a string sequence { S0, S1, S2, ... }, S0="A". Si can be constructed by Si-1: replace every letter "A" in Si-1 by "AAB", replace every letter "B" by "A". S0, S1="AAB", S2="AABAABA". Your task is to find the location of the k-th letter "A" in S100. For example, the location of the 1st "A" is 1, the 2nd is 2, the 3th is 4. 输入Input contains several cases, each case contains an integer k ( 1 ≤ k < 231 ) in one line. Input is terminated by one line contains one zero. 输出Description Consider a string sequence { S0, S1, S2, ... }, S0="A". Si can be constructed by Si-1: replace every letter "A" in Si-1 by "AAB", replace every letter "B" by "A". S0, S1="AAB", S2="AABAABA". Your task is to find the location of the k-th letter "A" in S100. For example, the location of the 1st "A" is 1, the 2nd is 2, the 3th is 4. Input Input contains several cases, each case contains an integer k ( 1 ≤ k < 231 ) in one line. Input is terminated by one line contains one zero. Output For each case, output an integer in one line expressing the location of the k-th "A". Sample Input 1 Sample Output 1 Source 样例输入1 样例输出1 作者 |