You are not logged in. Please login at www.codechef.com to post your questions!

×

Getting wrong ans because of improper placements of modulo. Need Help

I need To Find The Summation Of the Below Series: (n+1-1)C1+(n+2-1)C2+.........+(n+k-1)CK(Hint:(n+k-1)Ck=(n+k-1)C(K)+(n+k-1)C(k-1)) The ans should be printed as Modulo m

Here n=Len and k=N and m=1000003

 #include<stdio.h>

 #define M 1000003

 int main(){

int t=0;

long long int sum=0,L,R,N,init=0,i=0,Len=0;

scanf("%d",&t);

while(t-- > 0){

    scanf("%lld%lld%lld",&N,&L,&R);

    Len=R-L+1;

    if(R==L){

       printf("%lld\n",N%M);
    }

    else if(N<=Len){

    init=Len%M;

    sum=init;

    for(i=2;i<=N;i++){
       //I think beacuse of improper placements of modulo m getting wromg ans
       init=((((init%M)*((Len%M+i%M-1)%M))%M)/(i%M))%M;


       //printf("%lld",init);
       sum=(sum%M+init%M)%M;
    }

    printf("%lld\n",sum);

    sum=0;
    }

}
//getch();

return 0;

} I am getting wrong ans because of improper placements of modulo

asked 09 Apr '15, 12:04

aniruddha_paul's gravatar image

2★aniruddha_paul
35213
accept rate: 0%

edited 09 Apr '15, 13:21

admin's gravatar image

0★admin ♦♦
19.7k350498541


@aniruddha_paul: I see that you have participated in the April'15 long contest and this post is a clear violation of the contest rule. Please, remove the post. In case you need help you can always google it or else wait for the editorials to come. @admin ++

link

answered 09 Apr '15, 16:01

codedecode0111's gravatar image

5★codedecode0111
3201215
accept rate: 0%

how to remove it??

(09 Apr '15, 16:48) aniruddha_paul2★

but my points also gt removed!

(09 Apr '15, 16:49) aniruddha_paul2★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,056
×335

question asked: 09 Apr '15, 12:04

question was seen: 705 times

last updated: 09 Apr '15, 16:49