Submit | All submissions | Best solutions | Back to list |
UDIVSUM - The Sum of Unitary Divisors |
A natural number is a unitary divisor of if is a divisor of and if and are coprime.
Let be the sum of the unitary divisors of . For example, , and .
Let
Given , find .
Input
There are multiple test cases. The first line of input contains an integer (), indicating the number of test cases. For each test case:
The first line contains an integer ().
Output
For each test case, output a single line containing .
Example
Input:
7 1 2 3 4 5 100 100000
Output:
1 4 8 13 19 6889 6842185909
Information
There are 8 Input files.
- Input #1: , TL=1s
- Input #2: , TL=5s
- Input #3: , TL=5s
- Input #4: , TL=5s
- Input #5: , TL=10s
- Input #6: , TL=10s
- Input #7: , TL=10s
- Input #8: , TL=10s
My unoptimized C++ solution runs in 8.9 sec (total time). And with some constant optimization, now my C++ solution runs in 1.03 sec (total time).
Added by: | zimpha |
Date: | 2018-01-17 |
Time limit: | 1s-10s |
Source limit: | 10240B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
hide comments
2018-01-18 17:28:55 zimpha
@[Rampage] Blue.Mary, I don't think so. It just replaces uint64_t with uint128_t, and it's better to focus more on the method. |
|
2018-01-18 11:14:50 [Rampage] Blue.Mary
It's more interesting if the problem doesn't require the answer to modulo 2^64 :P |