P3150 pb的游戏(1)

P3150 pb的游戏(1)

解题思路:当m是1的时候zs赢。当m=2的时候,pb只能分成2=1+1,对于zs来说无论选择哪个都是pb赢。对于m=3=1+2,zs选择2的话是一定会赢的,根据上一步的判断。m = 4…也是这样,于是就可以得出结论。m是奇数的时候zs赢,m是偶数的时候pb赢。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lf;
typedef unsigned long long ull;
typedef pair<ll,int>P;
const int inf = 0x7f7f7f7f;
const ll INF = 1e16;
const int N = 5e2+10;
const ull base = 131;
const ll mod =  1e9+7;
const double PI = acos(-1.0);
const double eps = 1e-4;

inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}
inline string readstring(){string str;char s=getchar();while(s==' '||s=='\n'||s=='\r'){s=getchar();}while(s!=' '&&s!='\n'&&s!='\r'){str+=s;s=getchar();}return str;}
int random(int n){return (int)(rand()*rand())%n;}
void writestring(string s){int n = s.size();for(int i = 0;i < n;i++){printf("%c",s[i]);}}
ll fast_power(ll a,ll p){
    ll ans = 1;
    while(p){
        if(p&1) ans = (ans*a)%mod;
        p >>= 1;
        a = (a*a)%mod;
    }
    return ans;
}


int main(){
    srand((unsigned)time(NULL));
    //freopen(  "out.txt","w",stdout);
    int t = read();
    while(t--){
        int n = read();
        if(n%2){
            puts("zs wins");
        }else puts("pb wins");
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_42868863/article/details/114546203