Friday, August 11, 2017

UVa problem solution 10110 - Light, more light

problem link:

Discuss: it is simple problem. if the number of divisor is odd then light is on otherwise off. you can determine it with perfect number if it is perfect square number then light off other wise on.


try yourself before see the code


#include<stdio.h>
int main()
{

    long long n,i,j,m;
    while(scanf("%lld",&n)==1)
    {
        if(n==0)
            break;
            m=sqrt(n);
            i=m*m;
       if(i==n)
            printf("yes\n");
        else
            printf("no\n");
    }
    return 0;
}

No comments:

Post a Comment