首页 > 其他 > 详细

【规律】Cunning Friends

时间:2019-08-23 00:43:22      阅读:202      评论:0      收藏:0      [点我收藏+]

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\n");
16         else printf("Win\n");
17     }
18     else if((sum-a[n])==(n-1))printf("Win\n");
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\n");
22         else printf("Lose\n");
23     }
24     else printf("Lose\n");
25   
26     return 0;
27 }
View Code

 

【规律】Cunning Friends

原文:https://www.cnblogs.com/Osea/p/11397570.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!