本文主要是介绍博弈论刷题记录,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
//不想学新东西了(
肥猫的游戏
#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;
}
这篇关于博弈论刷题记录的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!