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
| Author: | admin |
| Date Added: | 20-04-2009 |
| Time Limit: | 1 - 2 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC |
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