CZ_PROB2 - Sum of Factors

Find the sum of the factors of a number including 1 and the given number.

Input

Number of test cases T followed by T lines of number n.
0 < T <= 5000
0 < n <= 999999999
Note: The number will not have a very large prime factor.

Output

The sum of the factors for each test case.

Example

Input:
2
6
5

Output:
12
6

Added by:Rahul
Date:2007-03-10
Time limit:1s
Source limit:4000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:Siddharth Agarwal

hide comments
2018-08-19 08:45:03
Make sure you count sum of divisors, not prime factors. Also, even O(sqrt(n)) will TLE in Python, think of something better; statement contains a hint.
2017-10-28 04:00:16
Weak test cases :') AC in 1 go !
2017-10-01 14:38:43
why keep getting TLE?
2016-01-09 22:06:53
TLE
2014-12-02 02:10:20 Minsuk Kim
oh my goodness keep on getting TLE with python 2.7... :(
2014-09-27 16:47:48 CODER
I am getting the right answer for many numbers uptil 999999999 on Ideone for my code in C.
But for reasons I fail to understand, I keep getting a Wrong Answer whenever I submit it here.
Can someone please tell me what is wrong?
2014-04-10 04:45:58 Alberto Antonio C�ceres Peña
why my solution is time limit
--edit(francky)--> See the notes below, please. Code snipped.

Last edit: 2014-04-10 07:37:32
2013-05-15 15:41:34 Batzorig
@Daniel
your solution exactly get TLE
because yours O(T*N*N)>1 second

Last edit: 2013-05-15 15:42:22
2010-10-29 22:29:05 Michael T
Incorrect description. n definitely can be more than 999,999,999. Got AC with n <= 1,999,999,999 assumption.

Last edit: 2010-10-29 22:29:34
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.