您的位置:首页 > 其它

2699: 16 and 18

2010-11-01 21:50 183 查看
2699: 16 and 18
Result TIME Limit MEMORY Limit Run Times AC Times JUDGE
1s 8192K 87 27 Standard

16 and 18 are good friends. They are playing a game.

The rules are as following:

(1) 16 and 18 will give numbers in turn. At first 16, then 18, and then 16...
(2) If the previous one give a number A, the number the next one gives, namely B, must satisfy that
1 <= B - A <= k.
(3) Who first gives the number larger than or equal to N will lose the game.
(4) The game always starts with 16, and he can only give a number from [1, k] in the first round.
(5) Suppose that both of them will try their best to win.
Input

In each line, there will be two integers N (0 < N <= 100, 000, 000) and k (0 < k <= 100). Input terminates when N = k = 0
Output

For each case, print the winner's name in each line.
Sample Input

1 1
30 3
10 2
0 0

Sample Output

18
16
18

#include
#include
#include
using namespace std;
//int abss (int a) { return a>=0?a:(-a); }

int main ()
{
int n,k;
while(cin>>n>>k)
{
if(n==0&&k==0) break;
if(n%(k+1)==1) cout<<"18"<
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: