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
darkhire21: 2015-08-10 20:31:35

At 3rd got AC

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.

Piyush Deshmukh: 2015-07-17 08:13:27

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.

scyth3r: 2015-07-15 13:54:19

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

Last edit: 2015-07-15 20:36:15
QuickGun93: 2015-07-13 06:47:50

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

arcane_achal: 2015-07-06 12:50:55

I am getting the tle error can someone help

Last edit: 2015-07-06 12:52:56

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