A person is responsible for switching bulbs in the corridor. There are n bulbs (numbered from 1 to n) in the corridor, and he will go back and forth to N;
At the beginning of the I-th step, he will switch the light bulb whose number can be divisible by I;
Now we need to figure out whether the last light bulb (number N) is bright or dark after N trips.
Analysis: mathematics. This question is the parity of the number of N factors.
If X | N, N/X | n is displayed in pairs;
Here is a special case. If n is the total number of workers, SQRT (n) only appears once;
Therefore, if n is the number of complete integers, the factor is an odd number. Otherwise, the factor is an even number.
Note: int cannot be stored (⊙ _ ⊙ ).
#include <iostream>#include <cstdlib>#include <cmath>using namespace std;int main(){long long n;while (cin >> n && n) {long long v = (int)sqrt(n+0.0);if (v*v == n)cout << "yes" << endl;else cout << "no" << endl;}return 0;}
Ultraviolet A 10110-light, more light