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"<
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"<
相关文章推荐
- joj 2699: 16 and 18 博弈 最后一个取石子者输
- JAVA基础编程50题(16-18题)详解
- Codecraft-18 and Codeforces Round #458 (Div. 1 + Div. 2, combined) B题(博弈)
- 16系列和18系列的不同
- Think Python - Chapter 16 - Classes and functions
- Manthan, Codefest 16 -A Ebony and Ivory
- #18 – Silverlight and WPF Differences(Silverlight和WPF的区别)
- RH033读书笔记(16)-Lab 17 Installation and Administration Tools
- Python 刷题日记:LeetCode: 1&15&16-Two Sum and 3Sum
- SYSVOL and NETLOGON not shared on Win12/16
- Codecraft-18 and Codeforces Round#458 C. Travelling Salesman and Special Numbers(数位DP)
- Codecraft-18 and Codeforces Round #458 (Div. 1 + Div. 2, combined) .A-2018.1.20
- 犀牛书第五版读书笔记——Chapter 16. Cascading Style Sheets and Dynamic HTML
- Library Organization and Containers(Chapter 16 of The C++ Programming Language)
- Snort 3 on Ubuntu 14 and 16(译)
- [Career Cup 11][subjects from 57~59] Chapter 18 Thread and locks
- Manthan, Codefest 16 A. Ebony and Ivory 水题
- C程序设计语言 1-16 1-17 1-18 1-19
- Lesson 18: SDK文档:Tutorial 7 Texture Mapping and Constant Buffers分析
- !!!Chapter 16 Templates and Generic Programming