You are not logged in. Please login at 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

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;


answered 05 Feb '14, 19:51

vermashubhang's gravatar image

accept rate: 23%

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: 04 Feb '14, 19:55

question was seen: 1,162 times

last updated: 05 Feb '14, 19:51