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

×

Marbles wrong answer

Can anyone tell me where I went wrong in the Marbles problem? I dont see any fault in my Solution.

asked 04 Feb '14, 19:55

susobhang70's gravatar image

3★susobhang70
163
accept rate: 0%


Your solution is correct but the only problem is that value of comb() and the factorial() function which have defined are exceeding the range of long integers for larger values. The solution is always within the range of long64 so if you try to do the divide and multiply efficiently without going out of the range you would get the solution excepted. So efficient way of doing it linearly would be somewhat like this :

n C r can be found out by from n C 1 by multiplying (n-i) and dividing by (i+1) and going iteratively till i = r-1 starting from i = 1;

link

answered 05 Feb '14, 19:51

vermashubhang's gravatar image

5★vermashubhang
1.5k11025
accept rate: 23%

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:

×2,000
×1,767
×1,388
×471
×227
×8

question asked: 04 Feb '14, 19:55

question was seen: 1,116 times

last updated: 05 Feb '14, 19:51