【规律】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\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

 

转载于:https://www.cnblogs.com/Osea/p/11397570.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值