Links: Https://www.nowcoder.net/acm/contest/75/F
Source: Niu Ke Net
Time limit: C/s 1 sec, other languages 2 seconds
Space limitations: C/C + + 32768K, other languages 65536K
64bit IO Format:%lld
Title Description
A total of n heap of stones, known to the number of stones in each heap, two people take the stones in turn, each time can only select a heap of n heap stones to take a certain number of stones (at least one), after the son, you can also be the gravel of the remaining stones randomly selected to be placed on any other heap or several piles. Waiting for someone who can't take the midnight show that the person lost the game. Note: After a heap of stones has no children, it is no longer possible to place stones here.
Let's say that every time a calf takes a pebble, and both sides are absolutely smart, now give you the number of stones and the number of stones per heap, and determine if the Mavericks will win.
Input Description:
There may be multiple sets of test data (no more than 1000 test data groups)
The first line of each set of test data is an integer representing N (1<=n<=10)
The second line is n integers representing the number of stones in the heap. (the number of stones per heap is not more than 100)
When the input n is 0 o'clock, the input ends
Output Description:
For each set of test data, the output of WIN indicates that the calf can win, and the output lose indicates that the calf will fail.
Example 1 input
32 1 321 10
Output
Winlose
Analysis: If the initiator gets 22 pairs of stones, such as (2,2,1,1), (in) paired, (2,2) paired. Then you must lose.
Because the latter can be made into a mirror operation, so that the stone is still 22 pairs.
And if the initiator does not get 22 pairs of stones can use the largest pile of stones to make all the remaining stones 22 pairs, you must win.
The code is as follows:
#include <iostream>#include<cstring>#include<cstdio>using namespacestd;intf[ the];intx;intMain () {intN,flag; while(SCANF ("%d", &n)! =EOF) { if(n==0) Break; Flag=1; for(intI=1; i<=n;i++) {cin>>x; F[X]^=1; } for(intI=1; i<=n;i++) { if(f[x]==1) {flag=0; Break; } } if(flag==1) puts ("lose"); ElsePuts"Win"); } return 0;}
2018 National multi-school algorithm winter training Camp practice Competition (third game) calf re-war (game)