第14章 博弈论基础(《C++编程与信息学竞赛数学基础》)

张开发
2026/4/6 14:06:01 15 分钟阅读

分享文章

第14章 博弈论基础(《C++编程与信息学竞赛数学基础》)
1、T557802 062-14-C01-取硬币游戏https://www.luogu.com.cn/problem/T557802#include bits/stdc.h using namespace std; int main() { int n; while(cinnn!0) { if(n2) coutAliceendl; else coutBobendl; } return 0; }2、T553290 06-14-C02-遥控机器人https://www.luogu.com.cn/problem/T553290#include bits/stdc.h #define ll long long using namespace std; int solve(){ ll d,k,n,x,y; cindk; nd/(sqrt(2)*k); x(n1)*k; yn*k; if(x*xy*yd*d){ coutBob\n; }else{ coutAlice\n; } return 0; } int main() { int t; cint; while(t--){ solve(); } return 0; }3、T553291 06-14-C03-欧几里德游戏https://www.luogu.com.cn/problem/T553291#include bits/stdc.h using namespace std; bool f(int x,int y){ if(xy){ swap(x,y); } if(x%y0){ return 1; } if(x2*y){ return !f(x-y,y); } return 1; } int main() { int x,y; cinxy; if(f(x,y)){ coutAlice wins; }else{ coutBob wins; } return 0; }4、T553292 06-14-C04-Nim取石头游戏https://www.luogu.com.cn/problem/T553292#include bits/stdc.h using namespace std; int n,a[105],t; int main() { int i,j; cinn; cina[1]; ta[1]; for(int i2;in;i){ cina[i]; t^a[i]; } if(t0){ coutB wins; return 0; } coutA wins\n; int k31; while(!(t1k)){ k--; } for(int i1;in;i){ if(a[i]1k){ ji; break; } } coutj a[j]-(a[j]^t)\n; return 0; }5、T553293 06-14-C05-改数游戏https://www.luogu.com.cn/problem/T553293#include bits/stdc.h using namespace std; long long n,a[100],b[100],t; int main() { int i,j,x0; cinn; while(n) { b[x]n%10; n/10; } for(i1;ix;i){ t^b[i]; } if(t0){ coutB wins; return 0; } coutA wins\n; int k6; while(!(t1k)){ k--; } for(i1;ix;i){ if(b[i]1k){ ji; break; } } coutj (b[j]^t)\n; return 0; }6、T557803 062-14-D01-Nim取石头游戏(2)https://www.luogu.com.cn/problem/T557803#include bits/stdc.h using namespace std; void solve(int n) { int a[105],t; int i,j; cina[1]; ta[1]; for(int i2;in;i){ cina[i]; t^a[i]; } if(t0){ cout0\n; return; } int ans0; for(int i1;in;i){ if((a[i]^t)a[i]){ ans; } } coutans\n; return; } int main() { int n; while(cinn){ if(n0)break; solve(n); } }【数学基础】03-初等几何https://www.luogu.com.cn/training/675204#problemshttps://blog.csdn.net/dllglvzhenfeng/article/details/156864234第8章 组合数学《C编程与信息学竞赛数学基础》https://blog.csdn.net/dllglvzhenfeng/article/details/156614120

更多文章