HEU 4045 Divisor Summation
1
/**************************************
2
Problem: HEU 4045 Divisor Summation
3
Time: 0.6129 s
4
Memory: 2188 k
5
Accepted Time: 2009-03-24 13:47:33
6
Tips: http://hi.baidu.com/networker05/blog/item/4065f11f0cd9ea0b314e15c1.html
7
**************************************/
8
#include <stdio.h>
9
int main()
10
{
11
int a[500001] = {0,0} ;
12
int i,j;
13
for(i=1;i<=250000;i++ )
14
for(j=2;i*j<= 500000;j++)
15
a[i*j]+= i ;
16
scanf("%d",&i) ;
17
while(i--)
18
{
19
scanf("%d",&j);
20
printf("%d\n",a[j]);
21
}
22
return 0 ;
23
}
24
/**************************************2
Problem: HEU 4045 Divisor Summation3
Time: 0.6129 s4
Memory: 2188 k 5
Accepted Time: 2009-03-24 13:47:336
Tips: http://hi.baidu.com/networker05/blog/item/4065f11f0cd9ea0b314e15c1.html7
**************************************/8
#include <stdio.h>9
int main()10
{11
int a[500001] = {0,0} ;12
int i,j;13
for(i=1;i<=250000;i++ )14
for(j=2;i*j<= 500000;j++)15
a[i*j]+= i ;16
scanf("%d",&i) ;17
while(i--)18
{19
scanf("%d",&j);20
printf("%d\n",a[j]);21
}22
return 0 ;23
}24




浙公网安备 33010602011771号