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


CSEQ - Wrong Answer

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

almondpie's gravatar image

accept rate: 0%

edited 05 May '15, 12:57

admin's gravatar image

0★admin ♦♦

toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 21 Apr '15, 17:29

question was seen: 832 times

last updated: 05 May '15, 12:57