博弈论刷题记录

 //不想学新东西了(

肥猫的游戏

#include<bits/stdc++.h>
using namespace std;
int n;
bool check(int x,int y,int z){
    int pos=0;
    int m;
    m=y-x;
    if(m==1||m==n-1)pos++;
    m=z-y;
    if(m==1||m==n-1)pos++;
    m=z-x;
    if(m==1||m==n-1)pos++;
    if(pos==2)return 1;
    return 0;
}
void solve(){
    cin>>n;
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    for(int i=1;i<n-2;i++){
        int x,y,z;
        cin>>x>>y>>z;
    }
    if(check(a[0],a[1],a[2])){cout<<"JMcat Win"<<endl;return ;}
    else{
        if((n-2)&1)cout<<"PZ Win"<<endl;
        else cout<<"JMcat Win"<<endl;
    }
}
int main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int t;
    // cin>>t;
    t=1;
    while(t--)solve();
    return 0;
}

Roy&October之取石子

#include<bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    cin>>n;
    if(n%6==0)cout<<"Roy wins!"<<endl;
    else cout<<"October wins!"<<endl;
}
int main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int t;
    cin>>t;
    //t=1;
    while(t--)solve();
    return 0;
}

[NOIP2010 普及组] 三国游戏

#include<bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    cin>>n;
    vector<vector<int>>a(n+1,vector<int>(n+1));
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            cin>>a[i][j];
            a[j][i]=a[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        sort(a[i].begin(),a[i].end());
        ans=max(ans,a[i][n-1]);
    }
     cout<<1<<endl<<ans<<endl;
}
int main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int t;
    // cin>>t;
    t=1;
    while(t--)solve();
    return 0;
}

取数游戏 II

#include<bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    cin>>n;
    vector<int>a(n+1);
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++){
        if(a[i]==0){
            if(i%2==0){cout<<"YES"<<endl;return ;}
            break;
        }
    }
    for(int i=n;i>=1;i--){
        if(a[i]==0){
            if((n-i+1)%2==0){cout<<"YES"<<endl;return ;}
            break;
        }
    }
    cout<<"NO"<<endl;
}
int main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int t;
    // cin>>t;
    t=1;
    while(t--)solve();
    return 0;
}

欧几里德的游戏

#include<bits/stdc++.h>
using namespace std;
void solve(){
    int a,b;
    cin>>a>>b;
    bool p=1;
    while(a&&b){
        if(a<b)swap(a,b);
        if(a>=2*b){
            if(p)cout<<"Stan wins"<<endl;
            else cout<<"Ollie wins"<<endl;
            return ;
        }
        else {
            a-=b;
            if(a==0){
                if(p)cout<<"Stan wins"<<endl;
                else cout<<"Ollie wins"<<endl;
            }
        }
        p=!p;
    }
}
int main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int t;
    cin>>t;
    //t=1;
    while(t--)solve();
    return 0;
}

Roy&October之取石子II

#include<bits/stdc++.h>
using namespace std;
void solve(){
    int x;
    cin>>x;
    if(x%4==0)cout<<"Roy wins!"<<endl;
    else cout<<"October wins!"<<endl;
}
int main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int t;
    cin>>t;
    //t=1;
    while(t--)solve();
    return 0;
}

pb的游戏(1)

#include<bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    cin>>n;
    if(n&1)cout<<"zs wins"<<endl;
    else cout<<"pb wins"<<endl;
}
int main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int t;
    cin>>t;
    //t=1;
    while(t--)solve();
    return 0;
}

[DMOI-R1] 柯基棋

#include<bits/stdc++.h>
using namespace std;
void solve(){
    int n,q,s;
    cin>>n>>q>>s;
    if(n&1)cout<<"A won"<<endl;
    else cout<<"B won"<<endl;
}
int main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int t;
    cin>>t;
    //t=1;
    while(t--)solve();
    return 0;
}

[UESTCPC 2024] 取数游戏

#include<bits/stdc++.h>
#define int long long
using namespace std;
void solve(){
    int n;
    cin>>n;
    vector<int>a(n+1);
    int sum=0;
    for(int i=1;i<=n;i++)cin>>a[i],sum+=a[i];
    for(int i=1;i<=n;i++){
        if(a[i]>sum/2){cout<<"YES"<<endl;return ;}
    }
    if(n&1)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}
signed main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int t;
    cin>>t;
    //t=1;
    while(t--)solve();
    return 0;
}

「LAOI-5」拼图

#include<bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    cin>>n;
    if(n>5)cout<<"Alice"<<endl;
    else cout<<"Shinobu"<<endl;
}
int main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int t;
    cin>>t;
    //t=1;
    while(t--)solve();
    return 0;
}

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值