2014
02-17

# Clocks

There are N clocks in the room. The clock is so weird that it has only four states: 3 o’clock, 6 o’clock, 9 o’clock, 12 o’clock, represented by 1,2,3,0.(i.e, state 1 means 3 o’clock, and so on). Now giving you the initial state of N clocks, and N operations you can use to make all the clocks into the state 12 o’clock. Each operation M[i](1<=i<=N) represents by a vector size of N, M[i][j] is 0 or 1. When you use operation M[i] on the N clocks, M[i][j] = 0 means the j-th clock will not make any change, M[i][j] = 1 means the j-th clock will turn into the next state (i.e, 3 o’clock –> 6 o’clock, 6 o’clock –> 9 o’clock, 9 o’clock –>12 o’clock, 12 o’clock –>3 o’clock). You should note that you can use each operation at most 3 times.

Each test case contains a single integer N (1<=N<=50), indicating the number of clocks. The next following line contains N integers (each integer is in the range [0, 3]), meaning the initial state of N clocks. The next coming N lines each line contains N integers 0 or 1, each line describes an operation. The input is terminated by a set starting with N = 0.

Each test case contains a single integer N (1<=N<=50), indicating the number of clocks. The next following line contains N integers (each integer is in the range [0, 3]), meaning the initial state of N clocks. The next coming N lines each line contains N integers 0 or 1, each line describes an operation. The input is terminated by a set starting with N = 0.

3
3 3 3
1 0 0
0 1 0
0 0 1
3
3 3 3
1 1 0
1 0 0
0 1 0
3
3 3 3
1 1 1
0 1 0
0 0 1
0

Yes
No
Yes

1. 为什么for循环找到的i一定是素数叻，而且约数定理说的是n=p1^a1*p2^a2*p3^a3*…*pk^ak，而你每次取余都用的是原来的m，也就是n