Skip to content

Commit

Permalink
Update baicizhanxiaomi.md
Browse files Browse the repository at this point in the history
  • Loading branch information
0xkookoo authored Sep 20, 2018
1 parent c501f00 commit dd22af3
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/baicizhanxiaomi.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,33 @@ END
"""


“”“不知道谁的题目
三种颜色的球
”“”



class Solution(object):
res = 0
def cal_next(self, p, q, r, prev):
tmp = [p, q, r]
cur_max = max(tmp)
# 此时前面排好了且都满足,想要不相邻,数量最多的球中间的所有空格
# 必须小于或等于另外两个球的数量,否则说明此时排列不合法直接return
if cur_max - 1 > sum(tmp) - cur_max:
return
if p == q == r == 0:
self.res += 1
return
if p > 0 and prev != 'p':
self.cal_next(p-1, q, r, 'p')
if q > 0 and prev != 'q':
self.cal_next(p, q-1, r, 'q')
if r > 0 and prev != 'r':
self.cal_next(p, q, r-1, 'r')

s = Solution()
p, q, r = [int(i) for i in input().split()]
s.cal_next(p, q, r, '')
print(s.res)


```

0 comments on commit dd22af3

Please sign in to comment.