您的位置:首页 > 移动开发

TOJ 3471.Happy XiaoXiao Guo

2017-07-10 17:02 330 查看
题目链接:http://acm.tju.edu.cn/toj/showp3471.html

3471. Happy XiaoXiao Guo

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  toj 水题