Sicily 1923. Is It Nim?
来源:互联网 发布:网络老虎机熊猫机器 编辑:程序博客网 时间:2024/05/17 08:28
1923. Is It Nim?
Constraints
Time Limit: 2 secs, Memory Limit: 32 MB
Description
Alice and Bob play a new game again! There are N piles of stones. Each pile of stones may have different number of stones. They take turns to play, and Alice always play at the first turn.
At each turn, the player of this turn must choose at least one and at most K piles of stones and take at least one stone away from each of them. Who take the last stone of the game will win.
They both play optimally. But they want the game more interesting. So before the game start, Alice decide the number of stones in each pile, then Bob decide the number K.
Now Alice has decided it, and Bob want to be the winner. How many integers can be chosen by Bob as K will lead to his winning of the game?
Input
In the first line, there is one integer T(1<=T<=60).
Then T test cases follow. In the first line of each test cases, there is one integer N(1<=N<=1000), the number of piles in the game. In the second line of each test case, there are N integers, a1, a2 ... an, the number of stones in each piles.(1<=ai<=10^9)
Output
For each test case, output one line with only one integer, the number of integers that Bob can choose as K will lead to his winning of the game.
Sample Input
231 2 341 2 3 4
Sample Output
10
// Problem#: 1923// Submission#: 3279535// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/// All Copyright reserved by Informatic Lab of Sun Yat-sen University#include <stdio.h>#include <string.h>int main(){ int n,m,t,i,j,s[34]; scanf("%d",&n); while(n--){ memset(s,0,sizeof(s)); scanf("%d",&m); for(i=0;i<m;i++){ scanf("%d",&t); j=0; while(t!=0){ //化为二进制并将各位加到适当位置去 s[j]+=t%2; t/=2; j++; } } t=m; for(i=2;i<=m+1;i++) //判断不同的i(即k)是否会导致Bob必胜 for(j=0;j<34;j++){ if(s[j]%i!=0){ t--; break; } } printf("%d\n",t); } return 0;}
- Sicily 1923. Is It Nim?
- Sicily 2369. Nim-B Sum
- Sicily 11600. Pick It
- Sicily 1258. It
- sicily 1783 Large is Better
- sicily 1783. Large is Better
- Sicily 1783. Large is Better
- sicily 1558 He is Offside!
- Sicily 1305 Who’s Winner? (SOJ 1305) 【Nim问题】
- Sicily 1797. Do solve it directly
- Sicily 1797. Do solve it directly
- Sicily 1797. Do solve it directly
- Sicily 1906. There is a war
- It is my brithday
- Is it okay?
- It is my pass
- How is it going?
- It is more excited.
- Sicily 2287. Expression Equivalence (optional)
- Android 基于google Zxing实现二维码、条形码扫描,仿微信二维码扫描效果
- Java多线程
- Sicily 1149. 等价表达式
- 认识编程语言(c++)
- Sicily 1923. Is It Nim?
- Sicily 1308. Dependencies among J
- FLV格式解析
- 如何找回tomcat管理员密码
- Sicily 1047. Super Snooker
- (2.1.1)JVM内容:Java 类加载与初始化
- Sicily 1454. Pseudoprime numbers
- Unity IK(反向运动学)初探
- 准备蓝桥杯--dyx--十进制转换十六进制