题目链接:http://acm.tju.edu.cn/toj/showp3471.html
Time Limit: 1.0 Seconds Memory Limit: 65536K
Total Runs: 271 Accepted Runs: 189
Xiao guo's brother have a son, his name is Xiaoxiao guo. In the morning, Xiao guo's brother and his wife went out. So Xiao guo must stay with her nephew. She decide to play a game with him. First, there is an empty hole, they take turns to put some stones in the hole. Every time, 1, 2, 4 or 5 stones were placed in the hole. Two players play in turn, until one player makes a number of stones to be N in the hole and wins the game. Xiaoxiao guo always dose first. Suppose that both Xiao guo and Xiaoxiao guo do their best in the game. Give you a number N, you are to write a program to determine Xiaoxiao guo will happy or not.
Input
The input contains several test cases. The first line of each test case contains an integer number N, denoting the number of stones in the hole finally. You may assume the number of stones in the hole will not exceed 10000. The last test case is followed by one zero.
Output
For each test case, if Xiaoxiao guo win the game,output "Happy", otherwise output "Unhappy".
Sample Input
3 4 7 120 0
Sample Output
Unhappy Happy Happy Unhappy
水题,找规律就行,Unhappy都是3的倍数。
#include <stdio.h>
int main(){
int n;
while(~scanf("%d",&n) && n)
(n % 3) ? printf("Happy\n") : printf("Unhappy\n");
return 0;
}