When submitting a solution in C++, please select either C++14 (GCC 6-32) or C++17 (GCC 7-32) as your compiler. ×

UnburnedZuko's blog

By UnburnedZuko, history, 18 months ago, In English

[problem:1739C]In the problem(this one), when finding combinations(just learned them while solving this problem), we add previous values from n-2 function calling, like this
~~~~~
def calc(n):
if n == 2:
return [1, 0, 1]
a = calc(n — 2)
return [comb(n — 1, n // 2) + a[1], comb(n — 2, n // 2) + a[0], 1]#[alex win,boris win,draw]
~~~~~

but why do we add up alex's winnings on n with boris's winnings during n-2? why does adding adding 1 players winnings with his losses with less cards make sense? Would appreciate a proper explanation from anyone. And is there something I need to study up on to get this? Thanks in advance.

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?