Skip to content

Instantly share code, notes, and snippets.

@theabbie
Created March 4, 2022 13:20
Show Gist options
  • Save theabbie/65447b23c0ceace3924646f596740df7 to your computer and use it in GitHub Desktop.
Save theabbie/65447b23c0ceace3924646f596740df7 to your computer and use it in GitHub Desktop.
Dcoder Coins & Countries Solution
t = int(input())
def numWays(n, r):
ways = 0
if r == 1:
return 1
if n == 0:
return ways
for i in range(1, n - r + 2):
ways += numWays(n - i, r - 1)
return ways
for _ in range(t):
n, r = input().split()
n, r = int(n), int(r)
print(numWays(n, r))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment