virtual hust 2013.6.20 数论基础题目 B- Light, more light

题目:Light, more light

思路:第一次做的时候是素数打表,然后分解质因式,求约数个数是不是奇数的,按理来说没错,但是就是过不了。

发现的一个陷阱是2^32-1这个值肯定不能用int,还是找不到分解质因数做法的错 ==

其实这个只要判断是不是完全平方数就ok了,不解释,自己看 

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
using namespace std;
int main()
{
    long long n;
    while(scanf("%lld",&n)!=EOF,n)
    {
        long long tmp=(long long)sqrt(n);
        if(tmp*tmp==n)
            printf("yes
");
        else
            printf("no
");
    }
    return 0;
}
View Code
原文地址:https://www.cnblogs.com/overflow/p/3146036.html