×

 0 For the problem CSEQ, I mathematically could prove that the total ways to create a non-decreasing sequence of length K (1<= K <= N) equals choose(K + R - L, K) (the same formula given in the ediorial). Then we can see that choose(K + R - L, K)*(K + R - L + 1)/(K + 1) equals choose(K + R - L + 1, K + 1). Hence in my code here, I wrote a for loop which starts with sumtemp intialised to 1 and which multiplies sumtemp with (j + R - L)/j thus creating the jth element of the sequence. Now this term is added to ans every time in the loop and I also have added the modulus statement there to avoid overflow. This gives me a correct ans to some cases which I found out manually and then verified with the code, but codechef isn't accepting my solution. Can anyone help me find the mistake in my approach? asked 21 Apr '15, 17:29 3●6 accept rate: 0% 0★admin ♦♦ 19.8k●350●498●541
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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,070
×856
×35

question asked: 21 Apr '15, 17:29

question was seen: 832 times

last updated: 05 May '15, 12:57