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
adi32_tomar: 2015-11-27 14:55:53

hey folks i am new here can u please tell me to see the correct solution of questions

an_shuman777: 2015-11-22 14:01:27

Same concept in c++ got AC but in PYTHON its TLE.

wojtekwariat: 2015-11-20 16:06:39

runtime error here @JAVA

Hugo Godoy: 2015-10-06 08:19:11

O(log n)

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.

darkhire21: 2015-08-19 17:08:26

In one go AC...!!!

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

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