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


hide comments
kirthi_ash1: 2015-10-03 12:41:23

i dont know what runtime error does my program have http://www.spoj.com/submit/DIVSUM/id=15280758.but when i run it in dev cpp its correct.pls give me a correct solution .and help me to find the error

Anchrondite: 2015-09-20 17:10:50

This is very bad .Costed one WA for answer of input 1 for which answer should be 1 but program requires it to be 0

dedeibel: 2015-09-10 21:07:52

Cannot be done in clojure, time limit is too small

Asish Panda: 2015-08-20 08:52:37

For python, use `sys.stdin.readlines()` to read the whole input then parse to give the output, if you are facing tle prolem.

abhinav: 2015-08-16 12:11:31

Can anybody tell me what is wrong with my code. I am getting correct answer's for all the test cases which I tried, but I am getting WA on submission(http://ideone.com/*********).

=(Francky)=> Please read the notes below (no source code here, nor in link), rather use the forum for any help.

Last edit: 2015-08-16 12:59:25
ROHIT Kumar: 2015-08-03 17:31:55

for 1 ans should be 0
...wasted my 5 submission...

akash: 2015-08-02 17:13:33

runtime error..!

ALi Ibrahim: 2015-07-26 22:16:15

Third Accepted, nice problem :)

ALi Ibrahim: 2015-07-26 15:12:01

amisha
you are printing so much, eg:printf("Input the number of test cases \n");
you should follow the output format.

QuickGun93: 2015-07-13 06:47:50

use c or c++ with long long. same logic in python gave tle


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