Pages

Sunday 30 September 2012

UVA - 10110 - Light, more light (C solution)

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

bool is_Psquare(long x) {
        long root = (long) (floor(sqrt(x) + 0.5));
        return root * root == x;
    }

int main()
{
        long x;
        while(1){
            scanf("%ld",&x);
            if(x==0)
                break;
            if(is_Psquare(x)){
                puts("yes");
            }else{
                puts("no");
            }
        }
    return 0;
}

No comments:

Post a Comment