Back to General discussions forum
#include<stdio.h>
int main()
{
int test,n,i,j,k,sum,arr[1000];
int seed=113,limit=10000007;
scanf("%d",&test);
for(i=0;i<test;i++)
{
scanf("%d",&n);
arr[i]=n;
}
sum=0;
for(j=0;j<test;j++)
{
sum=(sum+arr[j])*seed;
sum=sum%limit;
}
printf("\n");
printf("%d",sum);
printf("\n");
return 0;
}
When I give input 6(test) 3 1 4 1 5 9 ouput gives correct answer but submitted answer giving wrong answer
Ivan, Hi!
No need to post your solution, it's visible in your profile :)
Have you seen the very last line in the problem statement? Check if this is causing trouble in your case:
All input values are between 0 and 1,000,000,000 - be sure to take care of possible overflow in progress of calculations!
I.e. make small input with, say, just 3 values 999999998, 999999999, 1000000000 - and check with your code and with pencil
I understand.Thank you.