AFS2 - Amazing Factor Sequence (medium)
Warning
Here is a harder version of Amazing Factor Sequence .
To make things clear, you'll need a O(n^0.5) method to solve this problem. You'll need to be careful with container of C-like language, and/or you'll need to find some little optimizations with slower language.
The factor sequence
We define our factor sequence with:
a[0] = a[1] = 0, and
for n > 1, a[n] = a[n - 1] + sum({x | x < n and n % x = 0}).
Input
First line of input contains an integer T, the number of test cases.
Each of the next T lines contains a single integer n.
Output
For each test case, print a[n] on a single line.
Example
Input: 3 3 4 5
Output: 2 5 6
Constraints
0 < T < 101 0 < n < 12148001999
Numbers n are uniform-randomly chosen. Nmax was carefully chosen ;-) Time limit is ×2.5 my python one (2.56s). (Edited 2017-02-11, after compiler changes)
hide comments
mehmetin:
2015-01-29 17:41:22
Huge difference between my AC times with PYPY and Python 2.7, submitting the same code. Last edit: 2015-01-29 17:42:42 |
|
foureC:
2014-10-01 15:53:49
Can someone please give more test cases?
|
|
Ayush Rajoria:
2014-02-01 19:31:19
My 100th problem !!! |
|
Yashpal:
2013-07-04 17:56:20
Getting TLE & runtime error yet i used O(n^.5)....
|
|
Mohit Gupta:
2013-06-27 16:38:20
my solution id is 9562986
|
|
fR0DDY:
2013-06-13 14:07:49
My solution passes the time limit but I still think there are improvements. Can you give any hint?
|
|
[Lakshman]:
2013-05-11 16:38:49
Finally DONE ...feeling great after solving this...Don't know why getting incorrect answer with python...very poor in python...
|
|
Hardik:
2013-03-30 17:40:57
How to handle overflow ?????
|
|
darkshadows:
2013-03-25 05:29:30
well i have a sqrt(n) algo. coded in python... but i am getting TLE.....
|
|
Abhilash Kumar:
2013-03-24 09:46:26
|
Added by: | Francky |
Date: | 2013-03-16 |
Time limit: | 6.400s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | AFS |