Skip to content

Instantly share code, notes, and snippets.

@inage
Created December 7, 2013 14:05
Show Gist options
  • Select an option

  • Save inage/7841763 to your computer and use it in GitHub Desktop.

Select an option

Save inage/7841763 to your computer and use it in GitHub Desktop.
分割数
## 分割数
## http://rubyfiddle.com/riddles/b8293
n = 4
m = 3
M = 10000
res = 0
(1..m).each{|i|
Array(1..n).repeated_combination(i){|a|
res += 1 if a.inject(:+) == n
}
}
puts res % M
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment