ZOJ2095
Divisor Summation
#include <stdio.h>
#define N 500002
int result[N] = {0};
void Calc()
{
int i,j;
for(i = 2; i <= 250000; i++)
for(j = 2; i * j < N; j++)
result[i * j] += i;//i的倍数均加i
}
int main()
{
int t, n;
Calc();
result[1] = -1;//对1做特殊处理
while(scanf("%d",&t) != EOF)
while(t-- && scanf("%d",&n))
printf("%d\n",result[n] + 1);
return 0;
}
#define N 500002
int result[N] = {0};
void Calc()
{
int i,j;
for(i = 2; i <= 250000; i++)
for(j = 2; i * j < N; j++)
result[i * j] += i;//i的倍数均加i
}
int main()
{
int t, n;
Calc();
result[1] = -1;//对1做特殊处理
while(scanf("%d",&t) != EOF)
while(t-- && scanf("%d",&n))
printf("%d\n",result[n] + 1);
return 0;
}