博弈例题

巴什博弈

尼姆博弈

威佐夫博弈

公平组合博弈

eg.1 hdu2147
AC代码:

#include <bits/stdc++.h>
using namespace std;

int n, m;

int main(){
    
    
	while(cin >> n >> m){
    
    
		if(n == 0 && m == 0) break;
		if(n % 2 == 0 || m % 2 == 0) cout << "Wonderful!" << endl;
		else cout << "What a pity!" << endl;
	}
	return 0;
}

eg.2
https://vjudge.net/contest/429544#problem/D
超简单,读懂题就会写(不属于上面的任何一种博弈)

#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 4;

int t;
int n, m;
int a[N], b[N];

int main(){
    
    
	cin >> t;
	while(t--){
    
    
		cin >> n >> m;
		for (int i = 1; i <= n; ++i) cin >> a[i];
		for (int j = 1; j <= m; ++j) cin >> b[j];
		if(n <= m) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	
	return 0;
}

猜你喜欢

转载自blog.csdn.net/LXC_007/article/details/114551864
今日推荐