2793 教官的游戏

题目描述 Description

有N个学生刚吃完饭,准备出食堂。

国防学校有个规矩:必须2人一排或3人一列离开。

两个教官A,B轮流取2或3人,谁先取完谁就赢得游戏。(A先取)

若两人都用最优策略,谁会赢?

输入描述 Input Description

N

输出描述 Output Description

A赢输出1;

B赢输出-1;

平局输出0;

若人数为负,则教官NC了,输出120.(该打120了)

样例输入 Sample Input

7

样例输出 Sample Output

1

数据范围及提示 Data Size & Hint

N<=10000.

思路

水题,只是看到钻石级才随手做的

代码

#include<iostream>
#include<cstdlib>
#include<cstdio>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    if (n<0) {cout<<"120"<<endl; return 0;}
    if ((n%5)==2) {cout<<'1'<<endl; return 0;}
    if ((n%5)==3) {cout<<'1'<<endl; return 0;}
    if ((n%5)==0) {cout<<"-1"<<endl; return 0;}
    cout<<'0'<<endl;
    return 0;
}

结果

 

posted on 2014-09-17 17:02  seekdreamer  阅读(191)  评论(0编辑  收藏  举报