DIVCNT3 - Counting Divisors (cube)


Let σ0(n)\sigma_0(n) be the number of positive divisors of nn.

For example, σ0(1)=1\sigma_0(1) = 1, σ0(2)=2\sigma_0(2) = 2 and σ0(6)=4\sigma_0(6) = 4.

Let S3(n)=i=1nσ0(i3).S_3(n) = \sum _{i=1}^n \sigma_0(i^3).

Given NN, find S3(N)S_3(N).

Input

First line contains TT (1T100001 \le T \le 10000), the number of test cases.

Each of the next TT lines contains a single integer NN. (1N10111 \le N \le 10^{11})

Output

For each number NN, output a single line containing S3(N)S_3(N).

Example

Input

5
1
2
3
10
100

Output

1
5
9
73
2302

Explanation for Input

- S3(3)=σ0(13)+σ0(23)+σ0(33)=1+4+4=9S_3(3) = \sigma_0(1^3) + \sigma_0(2^3) + \sigma_0(3^3) = 1 + 4 + 4 = 9

Information

There are 5 Input files.

- Input #1: 1N100001 \le N \le 10000, TL = 1s.

- Input #2: 1T300, 1N1081 \le T \le 300,\ 1 \le N \le 10^{8}, TL = 20s.

- Input #3: 1T75, 1N1091 \le T \le 75,\ 1 \le N \le 10^{9}, TL = 20s.

- Input #4: 1T15, 1N10101 \le T \le 15,\ 1 \le N \le 10^{10}, TL = 20s.

- Input #5: 1T2, 1N10111 \le T \le 2,\ 1 \le N \le 10^{11}, TL = 20s.

My C++ solution runs in 7.1 sec. (total time)

Source Limit is 12 KB.


hide comments
Min_25: 2018-01-11 17:40:23

@zimpha: Probably, my solution runs in O(n2/3+ϵ)O(n^{2/3+\epsilon}) time (and uses a similar formula as yours).

Your solution will run faster than mine if it uses "int64 u = nd / (a * a);" (or "int64 u = nd / (double)(a * a);") on line 74.

Last edit: 2018-01-11 17:58:20
zimpha: 2018-01-11 15:33:31

@Min_25, what is the time complexity of your solution. I use an O(n^(2/3)) method, but I still cannot run as fast as you can.

Abhay Pratap: 2015-01-17 20:30:17

compiler was running up to case 5, then showed time limit exceeded...does it means only case 5 is not in the time_limit?

TURTLE: 2014-10-19 11:11:41

@Min_25- Please give some hints about the question. Its been a while and the question is yet unsolved! Thanks in advance.

--Min_25-->
The Dirichlet convolution is the key to DIVCNT2 <s>and DIVCNT3</s>.

Last edit: 2016-05-20 09:58:46

Added by:Min_25
Date:2014-06-29
Time limit:1s-20s
Source limit:12288B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 GOSU