#include <time.h>
#include <math.h>
#include <stdio.h>
int Get(long n)
{
long aa = sqrt(n);
long temp = 1;
for (long i = 2;i < aa;++i)
if (n % i == 0)
{
temp += i;
temp += n / i;
}
if (aa * aa == n)
temp += aa;
return temp == n;
}
int main()
{
clock_t t2, t1 = clock();
int count = 1;
for (long n = 28; n <= 1000000;++n)
if (Get(n))
printf("%d\t", n), ++count;
printf("\n%d\n", count);
t2 = clock();
printf("%.3f s\n", (t2-t1)/1000.0);
return 0;
}
[
本帖最后由 azzbcc 于 2013-3-20 13:48 编辑 ]