DIVSUM - Divisor Summation

Given a natural number n (1 <= n <= 500000), please output the summation of all its proper divisors.

Definition: A proper divisor of a natural number is the divisor that is strictly less than the number.

e.g. number 20 has 5 proper divisors: 1, 2, 4, 5, 10, and the divisor summation is: 1 + 2 + 4 + 5 + 10 = 22.

Input

An integer stating the number of test cases (equal to about 200000), and that many lines follow, each containing one integer between 1 and 500000 inclusive.

Output

One integer each line: the divisor summation of the integer given respectively.

Example

Sample Input:
3
2
10
20

Sample Output:
1
8
22

Warning: large Input/Output data, be careful with certain languages


Added by:Neal Zane
Date:2004-06-10
Time limit:3s
Source limit:5000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All
Resource:Neal Zane

hide comments
2015-08-10 20:31:35
At 3rd got AC
2015-08-03 17:31:55 ROHIT Kumar
for 1 ans should be 0
...wasted my 5 submission...
2015-08-02 17:13:33 akash
runtime error..!
2015-07-26 22:16:15 ALi Ibrahim
Third Accepted, nice problem :)
2015-07-26 15:12:01 ALi Ibrahim
amisha
you are printing so much, eg:printf("Input the number of test cases \n");
you should follow the output format.
2015-07-17 08:13:27 Piyush Deshmukh
AC in first attempt. For those who are struggling with TLE, My algo works in O(log(n)+sqrt(n)) in C, 0.12 sec.
2015-07-15 13:54:19 scyth3r


Last edit: 2015-07-15 20:36:36
2015-07-15 08:35:38 scyth3r


Last edit: 2015-07-15 20:36:15
2015-07-13 06:47:50 QuickGun93
use c or c++ with long long. same logic in python gave tle
2015-07-06 12:50:55
I am getting the tle error can someone help


Last edit: 2015-07-06 12:52:56
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.