OpenJudge

1020:Anniversary Cake

总时间限制:
1000ms
内存限制:
65536kB
描述
Nahid Khaleh decides to invite the kids of the "Shahr-e Ghashang" to her wedding anniversary. She wants to prepare a square-shaped chocolate cake with known size. She asks each invited person to determine the size of the piece of cake that he/she wants (which should also be square-shaped). She knows that Mr. Kavoosi would not bear any wasting of the cake. She wants to know whether she can make a square cake with that size that serves everybody exactly with the requested size, and without any waste.
输入
The first line of the input file contains a single integer t (1 ≤ t ≤ 10), the number of test cases, followed by input data for each test case. Each test case consist of a single line containing an integer s, the side of the cake, followed by an integer n (1 ≤ n ≤ 16), the number of cake pieces, followed by n integers (in the range 1..10) specifying the side of each piece.
输出
There should be one output line per test case containing one of the words KHOOOOB! or HUTUTU! depending on whether the cake can be cut into pieces of specified size without any waste or not.
样例输入
2
4 8 1 1 1 1 1 3 1 1
5 6 3 3 2 1 1 1
样例输出
KHOOOOB!
HUTUTU!
来源
Tehran 2002, First Iran Nationwide Internet Programming Contest
全局题号
22
添加于
2009-10-29
提交次数
500
尝试人数
188
通过人数
111
您的评价 很水 简单 一般 较难 变态
  • 标签(多个标签用空格分隔):
  • 常用标签:
    递归   动态规划   贪心   搜索   枚举   模拟   数学   字符串处理   几何   高精度计算   图论  

共有6人评分

16.7%
33.3%
33.3%
0.0%
16.7%

已有的标签

搜索(4) 贪心(1) 递归(1) 枚举(1) 模拟(1)