【规律】Cunning Friends

Cunning Friends

 

题目描述

Anthony and his friends Ben and Chris decided to play a game. They have N piles of stones such that the ith-pile contains Ai stones. In one move a player chooses one pile and may take any non-zero number of stones from it. The players take turns. Anthony goes first then Ben and then Chris. If some player cannot make a move (no more stones exist) he loses. Ben colluded with Chris so their goal is to make Anthony lose. But Anthony doesn't want to lose. You have to find out if Anthony can avoid defeat if all players play optimally.

输入

The first line contains one integer N (1≤N≤1e5).
The next line contains N integers Ai (1≤Ai≤1e9).

输出

Print "Lose" if Anthony will lose in this game and "Win" otherwise.

样例输入

3
2 2 1

样例输出

Win

【待补】

放上队友的代码

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 const int maxn=1e5+5;
 5 ll a[maxn];
 6 int main()
 7 {
 8     int n;
 9     scanf("%d",&n);
10     ll sum=0;
11     for(int i=1;i<=n;i++){scanf("%lld",&a[i]);sum+=a[i];}
12     sort(a+1,a+n+1);
13     if(sum==n)
14     {
15         if(n%3==0) printf("Lose
");
16         else printf("Win
");
17     }
18     else if((sum-a[n])==(n-1))printf("Win
");
19     else if((sum-a[n]-a[n-1])==n-2)
20     {
21         if((n-2)%3 && (a[n-1]==2 || a[n]==2))printf("Win
");
22         else printf("Lose
");
23     }
24     else printf("Lose
");
25   
26     return 0;
27 }
View Code
原文地址:https://www.cnblogs.com/Osea/p/11397570.html