Re: Test instructions: There is an infinite number of lights in a row, at first it is closed, operation Infinite number of times, the first I operation will be numbered I and I in multiples of the electric light change the state. Ask the last I lamp status is open or off //behind the data ...
#include <stdio.h>intMain(){intB,N,I; while(scanf("%d",&N)!=Eof) {if(N==1)//First operation, the switch is all changed to 1;Printf("1\n");Else {B=0; for(I=2;I<=N;I+ +)//starting from 2 to determine the approximate, switch starting from 1; {if(N%I==0)B++; }if(B%2==0)//Determine the number of switch changes, (1 0 1 0 1 0 ...);Printf("1\n");ElsePrintf("0\n"); } }return0;}
Consider the second Test case:the initial condition:0 0 0 0 0 ... After the first Operation:1 1 1 1 1 ... After the second Operation:1 0 1 0 1 ... After the third Operation:1 0 0 0 1 ... After the fourth Operation:1 0 0 1 1 ... After the fifth Operation:1 0 0 1 0 ... The later operations cannot change the condition of the fifth lamp any more. So the answer is 0.
Hangzhou Electric 2053, easy to understand the C language code!!!