HDU 2897 bash 博弈变形

一堆石子N个 每个人最少取P个 最多取Q个 最后取光的人输 问谁赢

X=N%(P+Q)  X=0则先手取Q个必胜 X<=P则后手胜 X>P则先手取P个必胜

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;
int main()
{
    int n, p, q;
    while ( scanf ( "%d%d%d", &n, &p, &q ) != EOF )
    {
        int t = n % ( p + q );
        if ( t == 0 )
        {
            cout << "WIN" << endl;
        }
        else if ( t <= p )
        {
            cout << "LOST" << endl;
        }
        else
        {
            cout << "WIN" << endl;
        }
    }
}

 

posted @ 2019-10-09 18:17  Aragaki  阅读(102)  评论(0编辑  收藏  举报