# 取(m堆)石子游戏

##### Total Submission(s) : 2   Accepted Submission(s) : 2

Problem Description

m堆石子,两人轮流取.只能在1堆中取.取完者胜.先取者负输出No.先取者胜输出Yes,然后输出怎样取子.例如5堆 5,7,8,9,10先取者胜,先取者第1次取时可以从有8个的那一堆取走7个剩下1个,也可以从有9个的中那一堆取走9个剩下0个,也可以从有10个的中那一堆取走7个剩下3个.

Input

Output

Sample Input

2

45 45

3

3 6 9

5

5 7 8 9 10 0

Sample Output

No

Yes

9 5

Yes

8 1

9 0

10 3

Author

Zhousc

``` 1 #include<iostream>
2 #include<vector>
3 #include<cstdio>
4 using namespace std;
5 int main()
6 {
7     int n,m,i,x;
8     vector<int>arr;
9     while(scanf("%d",&n),n)
10     {
11          arr.clear();
12        for(x=i=0; i<n; i++)
13        {
14            scanf("%d",&m);
15            x^=m;
16            arr.push_back(m);
17        }
18        if(x)
19        {
20           printf("Yes\n");
21          for(i=0;i<n;i++)
22          {
23              int temp=x^arr[i];
24           if(temp<arr[i])
25               printf("%d %d\n",arr[i],temp);
26          }
27        }
28        else
29            printf("NO\n");
30     }
31     return 0;
32 }```

0 条评论

## 相关文章

### Tips for thrift

Introduction I have designed and developed game servers successfully with thrift...

37150

43950

### poj-----Ultra-QuickSort(离散化+树状数组)

Ultra-QuickSort Time Limit: 7000MS Memory Limit: 65536K Total Submission...

38860

### HDUOJ-----(1072)Nightmare(bfs)

Nightmare Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K ...

35570

### HDUOJ----2487Ugly Windows

Ugly Windows Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768...

30390

### 1615: [Usaco2008 Mar]The Loathesome Hay Baler麻烦的干草打包机

1615: [Usaco2008 Mar]The Loathesome Hay Baler麻烦的干草打包机 Time Limit: 5 Sec  Memory ...

343110

### POJ-2184 Cow Exhibition(01背包变形)

Cow Exhibition Time Limit: 1000MS Memory Limit: 65536K Total Submission...

314100

### hdu 2818 Building Block

Building Block Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/327...

36470

Jungle Roads Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768...

32570

### Peer Code Reviews Made Easy with Eclipse Plug-In

Origin Article: Peer Code Reviews Made Easy with Eclipse Plug-In Origin Author: ...

17960