Sicily 1873. The finale or the match?

博弈论游戏策略
本文介绍了一个基于取石子游戏的博弈策略,通过一系列的游戏规则,决定哪一方可以在观看电视节目的选择上取得胜利。游戏涉及数学逻辑和最优策略选择。

1873. The finale or the match?

Constraints

Time Limit: 1 secs, Memory Limit: 32 MB

Description

Alice:Bob, the finale of the teleplay “Catch the uncatchable” is going to be on tonight.
Bob:Alice, there is going to be a football match too, China VS Japan. It must be very drastic and stirring. Why not watch it instead?
Alice:But the comedy is so attractive and humorous that I’ve been anxious for it all day long. Contrarily, the football match is too boring. Just a crowd of men chase and kick the ball……

How could Alice catch the feeling of Bob’s, a super football fans. His enthuse over the match is like that of Alice’s over the teleplay. He wouldn’t concede and, at the same time, wouldn’t make Alice unhappy either.

Bob:Alice, let’s play the finger-guessing game. The one who wins makes the decision.
Alice:No, it depends on luck. Emm, see that pile of stones?

Finally they come to a compromise:Take the stone game.
There are N stones. Alice and Bob take turns to remove any number of stones from that pile. The first player takes away a certain number of stones (but no more than N). The second player does the same things likewise, and then comes the first player’s turn. Each time the player could take away at least one stone and no more than twice as many as the ones the last player removes. He who removes the last stone wins the game. Suppose that both Alice and Bob are very smart. Neither of them will make any mistake during the game. Of course, who wants to loose the chance to watch his favorite program? Bob, a gentleman, would let Alice take first.

Please give your hand to Alice to decide whether she has a winning strategy.

Input

The first line in the input is an integer T, indicating that there are T test cases. The next T lines consist of T positive integers, each one per line. All of the integers are more than 1 and less than 2^31.

Output

For each test case, output NO in one line if Alice will surely win or YES otherwise.

Sample Input

2
3
4

Sample Output

YES

NO

// Problem#: 1873
// Submission#: 3344924
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include <algorithm>
#include <iostream>
#include <string>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <vector>
#include <iomanip>
#include <map>
#include <stack>
#include <functional>
#include <list>
#include <cmath>
using namespace std;

int main() {

    std::ios::sync_with_stdio(false);
    int caseNum;
    cin >> caseNum;

    while (caseNum--) {
        int temp;
        cin >> temp;
        long long fi2 = 2;
        long long fi1 = 3;
        long long f = fi1 + fi2;
        bool lose = false;
        if (temp == fi2 || temp == fi1 || temp == 1) lose = true;
        while (temp >= f) {
            if (temp == f) {
                lose = true;
                break;
            }
            fi2 = fi1;
            fi1 = f;
            f = fi1 + fi2;
        }
        cout << (lose ? "YES" : "NO") << endl;
    }


    //getchar();
    //getchar();
    
    return 0;
}                                 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值