Banner Home Page DIY Contests Problems Ranklist Status Statistics
1034数据再次加强,如果还能水过我不管了……

综合训练——你猜

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 62   Accepted Submission(s) : 38

Font: Times New Roman | Verdana | Georgia

Font Size:

Problem Description

已知F(1) = a
F(x) = (x % 2 == 0) ? F(x / 2) + 1 : F((x + 1) / 2) * 3 - 2;
给出a, n,求F(n)

Input

输入包含多组数据
每组数据包含两个正整数a, n (1 <= a, n <= 100000)

Output

对于每组数据,输出F(n)的值

Sample Input

1 5
2 20

Sample Output

10
21

Author

916852

Statistic | Submit | Back