涛神的游戏

Description

涛神喜欢和队友玩一个游戏,规则如下:数字a,b,c,表示当前的数字是c,两人轮流往这个数上加b,当数字大于等于a时,比赛结束,最后一个加数的人获胜。每次都是由涛神先加,给定数字a,b,c,请你判断涛神最终能否取胜?如果能取胜,输出YES,否则输出NO。

Input

数据为多组 第一行一个整数T(1≤T≤1000) 随后有T行,每行包含3个整数a,b,c 1≤b,c<a≤10000

Output

对于每组数据 输出一行"Case #k: result",其中k表示第k组数据.如果能取胜,result即为YES,否则result为NO。 详见样例

Sample Input

2

10 1 3

10 1 4

Sample Output

Case #1: YES

Case #2: NO

Source

第八届北京交通大学ACM程序设计竞赛

#include <iostream>
#include <math.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    int count=t;
    while(t--){

        int a,b,c;
        cin>>a>>b>>c;
        int temp=a-c;
        int k=ceil((double)temp/b);
        if(temp<b||k%2==1)
        {
            cout<<"Case #"<<count-t<<": YES"<<endl;
        }
        else
        {
            cout<<"Case #"<<count-t<<": NO"<<endl;
        }
    }
}

 

posted @ 2014-10-19 15:40  史红星-shihongxing  阅读(218)  评论(0编辑  收藏  举报