Submit | All submissions | Best solutions | Back to list |
LCMSUM - LCM Sum |
Given n, calculate the sum LCM(1, n) + LCM(2, n) + .. + LCM(n, n), where LCM(i, n) denotes the Least Common Multiple of the integers i and n.
Input
The first line contains T the number of test cases. Each of the next T lines contain an integer n.
Output
Output T lines, one for each test case, containing the required sum.
Example
Input: 3 1 2 5 Output: 1 4 55
Constraints
1 ≤ T ≤ 300000
1 ≤ n ≤ 1000000
Added by: | Varun Jalan |
Date: | 2010-01-24 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: PERL6 |
Resource: | own problem used for Codechef Snackdown Onsite |
hide comments
|
||||||||
2016-07-08 16:59:03 vaibhav goyal
scanf is also giving tle's finally got ac by fast i/o nice problem :) |
||||||||
2016-07-04 05:39:57
learnt new concepts from this problem Last edit: 2016-07-04 05:40:16 |
||||||||
2015-10-06 13:41:37
getting tle in c as well as in python also. but learn a lot |
||||||||
2014-11-03 12:02:03 Infinity
interesting problem.Had to refer the web to get the first idea. Last edit: 2014-11-03 13:05:20 |
||||||||
2014-10-23 08:50:15 pankaj
final AC |
||||||||
2014-02-16 19:20:51 Bhavik
learnt something new..:) Last edit: 2014-02-16 19:21:14 |
||||||||
2013-09-20 20:53:58 adhikari vushesh babu
At last green light :) use scanf and printf instead of cin and cout which costed me many TLE. |
||||||||
2013-04-29 08:40:16 Ouditchya Sinha
Great Problem! Learnt a lot about totient function... But I think there's some server instability, my earlier solution ran in 4.19s on ideone & here it TLE'd, my improved solution ran in 0.42s on ideone & here it took 4.13s. Strange. :) |
||||||||
2013-04-29 06:55:43 Rajarshi Sarkar
One does not simply calculate LCM :D |
||||||||
2013-01-30 23:14:57 saket diwakar
finally got AC....:) same algo getting TLE in python..#strange Last edit: 2013-01-30 23:16:40 |