ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1055. Combinations

The algorithm for solving this problem. EASY TO UNDERSTAND !
For example :
N = 7 and M = 3
you see : 7!/(3!*4!) = (2*3*4*5*6*7)/(2*3*2*3*4) = (5*6*7)/(2*3) = 35
=> you need not to calculate the multiple but divide all numbers into prime
I assign : the left = (5*6*7), the right = (2*3)
after division the left :
5 = 5
6 = 2*3
7 = 7
you will count all prime, the result is following :
there are 1 primes with value of 2
there are 1 primes with value of 3
there are 1 primes with value of 5
there are 1 primes with value of 7
I put into the bracket (1,1,1,1)
after divison the right :
2 = 2
3 = 3
there are 1 primes with value of 2
there are 1 primes with value of 3
there are 0 primes with value of 5
there are 0 primes with value of 7
I put into the bracket (1,1,0,0)
the left - the right = (1,1,1,1) - (1,1,0,0) = (0,0,1,1)
and the result 0+0+1+1 = 2
2 is the result
GOOD LUCK !
Re: The algorithm for solving this problem. EASY TO UNDERSTAND !
Posted by nguyenductam 5 Apr 2010 08:52
Thank you ,but i don't think this is good algorithm. My opinion.