The powerful sumProblem code: C2 |
All submissions for this problem are available.
Let us calculate the sum of k-th powers of natural numbers from 1 to n. As the result can be quite large, output the result modulo some integer p.
Input
First t<=10 - the number of test cases.
Each test case consist of numbers: 1<=n<=1000000000, 1<=k<=100, 1<=p<=1000000000.
Output
For each test case, output the value: (1k+2k+...+nk) mod p.
Example
For input:
4 10 1 1000000 10 2 1000000 10 3 1000000 10 4 1000000
the correct output is:
55 385 3025 25333
| Date: | 2009-04-20 |
| Time limit: | 2s |
| Source limit: | 50000 |
| Languages: | C C99 strict C++ PAS gpc PAS fpc JAVA NICE JAR C# C#2 NEM ST ASM D FORT ADA BASH PERL PYTH RUBY LUA ICON PIKE PHP SCM guile SCM qobi LISP sbcl LISP clisp HASK CAML CLPS PRLG WSPC BF ICK TEXT |
Comments

Fetching successful submissions

the question looks simple.. but the chef is putting a hell of a test case it seems.. :)
yup...the huge test case is the only prblm to solve here :|
anybody knows wat's the meaning of runtime error (SIGARBT)
# include
#include
int powerOfN(int n, int k);
int main(){
int n, k,p ;
int result =0;
int i=0;
printf("\n Enter N:");
scanf("%d",
surprisd that nobody has submitted in C ?? is thr any reason for that??
obviously the test case would be n=10^9,k=100,p=10^9
No one seems to have submitted in Java so far. Any particular reasons for that? All my submissions get timed out when I program in Java. But the same logic runs fine with C . What is the reason?
@Siddharth My solution during the contest was in Java.
can i not submit