Submit | All submissions | Best solutions | Back to list |
PUCMM210 - A Summatory |
f(n) is defined as: f(n) = 13+23+33+...+n3, so it is the sum of the cubes of all natural numbers up to n.
In this problem you are about to compute,
f(1) + f(2) + f(3) + ... + f(n)
Input
The first line is an integer T (1 ≤ T ≤ 100,000), denoting the number of test cases. Then, T test cases follow.
For each test case, there is an integer n (1 ≤ n ≤ 1,000,000) written in one line.
Output
For each test case output the result of the summatory function described above.
Since this number could be very large, output the answer modulo 1,000,000,003.
Example
Input:
3
2
10
3
Output:
10
7942
46
Added by: | Olson Ortiz |
Date: | 2012-05-24 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | Used in 2nd dominican ACM-ICPC Warm Up 2012 Competition in PUCMM |
hide comments
|
|||||||||
2016-08-18 19:04:04
Precomputation Rocks :D |
|||||||||
2016-06-10 17:02:15
just proper use of modulus...!! cost me a lot WA's |
|||||||||
2016-05-26 12:20:53 KD
easy one 150th AC in one :P and precomputation :P |
|||||||||
2016-05-01 22:38:30 Nitin Sharma
Same logic converted from Java to c++ passes. Hate these kind of questions. |
|||||||||
2015-12-03 16:24:19
precomputation rules :) |
|||||||||
2015-06-29 20:36:54 ASHUTOSH DWIVEDI
few mins of paper work modular expo 0.13sec AC....... Last edit: 2015-06-29 22:11:27 |
|||||||||
2015-06-27 12:15:01 Ankush
Did it using the formula, got TLE in python using raw_input(). AC using faster I/O :D |
|||||||||
2015-06-25 08:47:07
using a formula in the lame way will not work i guess,, coz in the formula there is a division by 60 and the mod number is not power of 10. Use precomputation. |
|||||||||
2015-06-22 23:56:58 jas.py
i did make a formula but got WA used precomputation->AC |
|||||||||
2015-06-19 21:43:54 Bhuvnesh Jain
10 minutes of paper work... direct formula... no use of modular exponentiation or precomputation... AC in one go |