Problem PUCMM210
Separated from previous thread.
#include<stdio.h>
int main()
{
int t,n,i;
scanf("%d",&t);
while(t>0)
{
int s=0;
scanf("%d",&n);
for(i=n;i>0;i--)
{
s+=(n-i+1)*i*i*i;
if(s>1000000003)
s=s%1000000003;
}
printf("%d\n",s);
t--;
}
return 0;
}
Pls help!![/quote]
The issue is not the modulo operation. Didn't you check? Your code works fine for test cases 113, 114, 115, ...
You should think about overflow problems. What will your code do for test cases near the upper limit? i*i*i might be a huge number
And: it is possible to calculate the result directly, without iterating. You may want to seach the internet for formulas of "Series Sums of the Powers"...