博弈游戏
题目描述
Here is a simple game. In this game, there are several piles of matches and two players. The two player play in turn. In each turn, one can choose a pile and take away arbitrary number of matches from the pile (Of course the number of matches, which is taken away, cannot be zero and cannot be larger than the number of matches in the chosen pile). If after a player’s turn, there is no match left, the player is the winner. Suppose that the two players are all very clear. Your job is to tell whether the player who plays first can win the game or not.
输入
The input consists of several lines, and in each line there is a test case. At the beginning of a line, there is an integer M (1 <= M <=20), which is the number of piles. Then comes M positive integers, which are not larger than 10000000. These M integers represent the number of matches in each pile.
输出
For each test case, output "Yes" in a single line, if the player who play first will win, otherwise output "No".
样例输入
2 45 45
3 3 6 9
样例输出
No
Yes
#include<stdio.h>
int main()
{
int n,i,a[50];
int temp,ans;
while(~scanf("%d",&n))
{
temp=0;
ans=-1;
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(i==0)
ans=a[i];
else
ans=ans^a[i];
if(a[i]>1)
temp=1;
}
if(temp==0)
{
if(n%2==1)
printf("No\n");
else
printf("Yes\n");
}
else
{
if(ans==0)
printf("No\n");
else
printf("Yes\n");
}
}
return 0;
}
解题思路:http://www.voidcn.com/article/p-ryiojmgj-yc.html
bit
题目描述
Amtel has announced that it will release a 128-bit computer chip by 2010, a 256-bit computer by 2020, and so on, continuing its strategy of doubling the word-size every ten years. (Amtel released a 64-bit computer in 2000, a 32-bit computer in 1990, a 16-bit computer in 1980, an 8-bit computer in 1970, and a 4-bit computer, its first, in 1960.)
Amtel will use a new benchmark - the Factstone - to advertise the vastly improved capacity of its new chips. The Factstone rating is defined to be the largest integer n such that n! can be represented as an unsigned integer in a computer word.
Given a year 1960 ≤ y ≤ 2160, what will be the Factstone rating of Amtel's most recently released chip?
输入
There are several test cases. For each test case, there is one line of input containing y. A line containing 0 follows the last test case.
输出
For each test case, output a line giving the Factstone rating.
样例输入
1960
1981
0
样例输出
3
8
解题:https://www.cnblogs.com/ISGuXing/p/7301064.html
沙子的质量:https://blog.csdn.net/u014493323/article/details/103126478
蚂蚁问题:https://www.cnblogs.com/li-jia-hao/p/12702844.html