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
Mitch Schwartz: 2014-10-07 13:59:34

:(

I wrote to an admin about the mass change of many problems from Pyramid to Cube, it's very worrying.

The current Python results for this problem are also curious, with high memory and 0.00s time. I checked that psyco isn't available. There might be some bug there.

Last edit: 2014-10-07 14:49:21
Ujjwal Kumar Singh: 2014-08-01 10:17:37

he guys i am a newbie here i know just basic c++ things getting SIGSEGV error on spoj however code working fine in codeblocks application helpp plz

<snip>

Last edit: 2023-03-08 17:56:08
ashour: 2014-08-01 03:24:09

it gives me TLE
this my code : <snip>
could someone tell me why ?

Last edit: 2023-03-08 17:56:13
[Lakshman]: 2014-07-11 17:22:37

@Mehmet Inal I think there is already another tutorial version with 10^6 test cases and tight time limit. http://www.spoj.com/problems/CHKL/
and we have DIVSUM2 in classical as well.

mehmetin: 2014-07-11 16:42:01

Would it be possible that another version of this problem be put in classical section with tighter time limit and more test cases maybe? Or if there is such a version, which one is it?

Aakash Gupta: 2014-06-16 05:39:17

for 1 its 0 :)

Sumit Mishra: 2014-05-29 14:18:35

what answer expected if input is 1 ?

Mayur Aggarwal: 2014-05-21 10:25:49

How can I verify why my soultion is giving wrong answer, anymethod to get test case for which wrong answer coming
--ans(Francky)--> It is easy to build a brute-force solution (slower but correct) and compare with home made random cases (+ all small cases). It's a method to be used with most of problems. Good luck.

Last edit: 2014-05-21 10:53:32
Mayur Aggarwal: 2014-05-21 10:03:03

My code is also giving wrong answer, can anybody tell me the expected outputs for numbers 1 and the numbers which divisible by themself only ?
Any help would be appriciated

p@dfoot: 2014-05-19 20:38:05

Do we have to specify the number of inputs?


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