From 427304c80a2cdf8e5d4303ebc442c29029e45d02 Mon Sep 17 00:00:00 2001 From: JiayangWu <530081999@qq.com> Date: Thu, 5 Mar 2020 01:19:31 -0500 Subject: [PATCH] 2020-03-05 --- ...\345\210\206\347\263\226\346\236\234II.py" | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 "1103.\345\210\206\347\263\226\346\236\234II/1103-\345\210\206\347\263\226\346\236\234II.py" diff --git "a/1103.\345\210\206\347\263\226\346\236\234II/1103-\345\210\206\347\263\226\346\236\234II.py" "b/1103.\345\210\206\347\263\226\346\236\234II/1103-\345\210\206\347\263\226\346\236\234II.py" new file mode 100644 index 0000000..c988b09 --- /dev/null +++ "b/1103.\345\210\206\347\263\226\346\236\234II/1103-\345\210\206\347\263\226\346\236\234II.py" @@ -0,0 +1,20 @@ +class Solution(object): + def distributeCandies(self, candies, num_people): + """ + :type candies: int + :type num_people: int + :rtype: List[int] + """ + res = [0 for _ in range(num_people)] + cnt = 1 + while candies: + for i in range(num_people): + if candies >= cnt: + res[i] += cnt + candies -= cnt + cnt += 1 + else: + res[i] += candies + candies = 0 + break + return res \ No newline at end of file