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)
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.
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.
Precomputation Rocks :D
just proper use of modulus...!! cost me a lot WA's
Last edit: 2016-09-18 16:15:21
easy one 150th AC in one :P
Same logic converted from Java to c++ passes. Hate these kind of questions.
precomputation rules :)
Last edit: 2015-07-11 14:22:13
few mins of paper work modular expo 0.13sec AC.......Last edit: 2015-06-29 22:11:27
Did it using the formula, got TLE in python using raw_input(). AC using faster I/O :D
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.