1 2 3 4

codefoces 1397D Stoned Game

博弈论

https://codeforces.com/contest/1397/problem/D

如果随便取走,只要是奇数就是先手赢,现在他规定不能重复取前人取过的,那就意味着8 2 2 2 ,先手占领8,就必胜了,如果4 4 4 4 4 这样均势,a先手每次找最大的取,只要是奇数就能赢

想不到啊,这我有啥办法

#include<iostream>
using namespace std;
int n;
long long sum = 0;
long long list[200];

int main(){
	int t;
	cin>>t;
	while(t--){
		cin>>n;
		sum =0;
		for(int i=0;i<n;i++){
			cin>>list[i];
			sum += list[i];
		}
		int f = 0;
		for(int i=0;i<n;i++){
			if(list[i] > sum - list[i] || sum & 1){
				f = 1;
				break;
			}
		}
		if(f){
			cout<<"T"<<endl;
		}
		else{
			cout<<"HL"<<endl;
		}
	}
	return 0;
}

  

posted @ 2020-09-04 17:00  Lesning  阅读(215)  评论(0编辑  收藏  举报