Yitong_Qin and Xiaoyu_Chen are playing a game.There are N stones placed on the ground,forming a sequence.Thr stones are labeled from 1 to N.Yitong_Qin and Xiaoyu_Chen in turns take exactly two consecutive stones on the ground until there are no consecutive stones on the ground.That is,each player can take stone i and stone i+1 ,where 1≤i≤n−1
.If the number of stones left is odd,Yitong_Qin wins ,so Xiaoyu_Chen has to dance.Otherwise Xiaoyu_Chen wins Yitong_Qin has to dance.
Input
The input contains an integer N(1≤N≤5000)
,the number of stones.
Output
Output the guy has to dance.
Sample input and output
Sample Input | Sample Output |
---|---|
1 | Xiaoyu_Chen |
2 | Yitong_Qin |
5 | Xiaoyu_Chen |
题意:Yitong_Qin跟Xiaoyu_Chen两个人轮流取石子,石子共有N个,最后剩下的是奇数,Yitong_Qin赢, 所以Xiaoyu_Chen跳舞,否则Yitong_Qin跳舞,输出要跳舞的人。
解题思路:直接看N是奇数还是偶数。
代码:
#include<cstdio>
int main(){
int N,mod;
scanf("%d",&N);
mod=N%2;
if(mod==1){
printf("Xiaoyu_Chen");
}
else{
printf("Yitong_Qin");
}
return 0;
}