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-11-27 14:55:53
hey folks i am new here can u please tell me to see the correct solution of questions
2015-11-22 14:01:27
Same concept in c++ got AC but in PYTHON its TLE.
2015-11-20 16:06:39
runtime error here @JAVA
2015-10-06 08:19:11 Hugo Godoy
O(log n)
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
2015-09-20 17:10:50 Anchrondite
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
2015-09-10 21:07:52
Cannot be done in clojure, time limit is too small
2015-08-20 08:52:37 Asish Panda
For python, use `sys.stdin.readlines()` to read the whole input then parse to give the output, if you are facing tle prolem.
2015-08-19 17:08:26
In one go AC...!!!
2015-08-16 12:11:31 abhinav
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
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.