Zoj
1350 the drunk jailer
There was an incompetent prison director who went crazy one night. In 1st rounds, he opened all the prison doors, and in 2nd rounds He took 2, 4, 6 ...... The prison door was closed, 3rd rounds, 3, 6, 9 ...... If these prison doors are open, they will be closed. If they are closed, they will be opened. How many prison doors are there, how many times will they be done, and then they will be off work. There is one criminal in each prison. If the prison director can only run after work, how many criminals can he run away?
Idea: I was going to define several arrays to replace the opened and closed prison number (ultra-complicated). Later I found that, in fact, for a single prison gate, it can divide the round number in this round and operate on it. The class is added to the number of operations, including on, off, and on ...... As long as it is an odd number, it can be accumulated into the number of running ......
Code:
# Include <stdio. h> int main () {int I, J, K, G, F, a [1000], t, n; scanf ("% d", & T ); for (I = 1; I <= T; I ++) {scanf ("% d", & N); For (j = 0; j <= n-1; j ++) {A [J] = J + 1;} f = 0; For (j = 0; j <= n-1; j ++) {G = 0; for (k = 1; k <= N; k ++) {if (a [J] % K = 0) {g ++ ;}} if (G % 2 = 1) f ++;} printf ("% d \ n", f);} return 0 ;}