Day11 - Q - A Multiplication Game HDU - 1517

题目链接

本题很像bash博弈,但又有些许不同,因为这里是乘法,我们可以列出前几项可能

若n=2-9,那么first可以一次取完

若n=10-18,无论first怎么取,second都能一次取完

若n=19-162,那么无论second怎么取,first都能一次取完

若n=163-324 second一定可以取完

以此类推,类似bash博弈,每一组必胜必败态交换的距离为18的倍数,那么就将n/=18直到n<=18,然后判断即可

#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-x))
typedef long long LL;

void run_case() {
    double n;
    while(cin >> n) {
        while(n > 18) n /= 18;
        if(n <= 9) cout << "Stan wins.\n";
        else cout << "Ollie wins.\n";
    }
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    //int t; cin >> t;
    //while(t--) 
    run_case();
    cout.flush();
    return 0;
}
View Code

猜你喜欢

转载自www.cnblogs.com/GRedComeT/p/12341111.html
今日推荐