Pro.ID21689 TitleCube Title链接http://10.20.2.8/oj/exercise/problem?problem_id=21689 AC1 Submit5 Ratio20.00% 时间&空间限制描述Klins has a dramatic toy made of 27 blocks. The toy is illustrated in picture 1 below: The toy is made of 17 groups. Each group is composed of 3 or 2 blocks. Each junction between two consecutive groups can rotate 360 degrees. So if Klins is smart enough, he can use the toy to form a 3*3*3 cube (See picture 3). In picture 1 above, the first group has 3 blocks, the second group has 2 blocks, and the third has 3 ones, and so on. As the blocks in each group are connected by a bungee, they can never move out of the group whatever possible rotation is performed (See picture 2). But not all kinds of such toys that are made up of 27 blocks are possible to form a cube. Klins wants to know whether the given toy can form a cube or not. 输入The input contains multiple cases. The first line of input is the number of test cases ( ≤ 1500 ). For each case, there are 17 integers in a line, each of which is either 3 or 2, denoting the number of blocks in each group. These numbers are given in consecutive order, i.e. any two consecutive groups are assumed to be connected with each other. 输出Description Klins has a dramatic toy made of 27 blocks. The toy is illustrated in picture 1 below: The toy is made of 17 groups. Each group is composed of 3 or 2 blocks. Each junction between two consecutive groups can rotate 360 degrees. So if Klins is smart enough, he can use the toy to form a 3*3*3 cube (See picture 3). In picture 1 above, the first group has 3 blocks, the second group has 2 blocks, and the third has 3 ones, and so on. As the blocks in each group are connected by a bungee, they can never move out of the group whatever possible rotation is performed (See picture 2). But not all kinds of such toys that are made up of 27 blocks are possible to form a cube. Klins wants to know whether the given toy can form a cube or not. Input The input contains multiple cases. The first line of input is the number of test cases ( ≤ 1500 ). For each case, there are 17 integers in a line, each of which is either 3 or 2, denoting the number of blocks in each group. These numbers are given in consecutive order, i.e. any two consecutive groups are assumed to be connected with each other. Output For each test case, print one line of "yes" if a cube of 3*3*3 can be formed using the given toy, otherwise print "no". Sample Input 2 Sample Output yes Source 样例输入2 样例输出yes 作者 |