UVA10110 Light, more light

链接地址

分析:

如果n能被a整除,那么一定存在一个b使得a*b = n。开关经两次变化相当于没有变化。那么只要看a = b的那种特殊情况就OK了。

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(){
    unsigned n, k;
    while(scanf("%d", &n) == 1 && n){
        k = (int)sqrt(n*1.0);
        if(k*k == n){
            printf("yes\n");
        }
        else printf("no\n");
    }

    return 0;
}

 

posted on 2013-04-02 13:38  Still_Raining  阅读(129)  评论(0编辑  收藏  举报