#1450461

Solution for 0030: Sum of Integers by iwamot

Source Code Status Test Cases
    Policy: public     Reviewed: 79    
00.02 sec    6092 KB    17 lines     275 bytes    2015-07-18 21:57
def dfs(i, sum, n, s)
  return (sum == s) ? 1 : 0 if n == 0
  return 0 if i > 9

  ans = 0
  ans += dfs(i + 1, sum + i, n - 1, s)
  ans += dfs(i + 1, sum, n, s)
  ans
end

while true
  n, s = gets.split(' ').map(&:to_i)
  break if n == 0 && s == 0
  puts dfs(0, 0, n, s)
end


Compile Error Logs:
You are not authorized to see the message.

Status
Judge: 1/1 Ruby CPU: 00.02 sec Memory: 6092 KB Length: 275 B 2015-07-18 21:57 2015-07-18 21:57
Results for testcases
Case # Verdict CPU Time Memory In Out Case Name
Case #1: : Accepted 00.02 sec 6092 KB
< prev | / | next >  
 
Judge Input #  ( | ) Judge Output #  ( | )


Comments
 
 Under Construction.
 
Categories
 
 
Free Tags