diff --git a/笔试+面试题汇总/2021-8-2 shopee-提前批-笔试/2021-8-2 shopee-提前批-笔试 .pdf b/笔试+面试题汇总/2021-8-2 shopee-提前批-笔试/2021-8-2 shopee-提前批-笔试 .pdf new file mode 100644 index 0000000..524e22d Binary files /dev/null and b/笔试+面试题汇总/2021-8-2 shopee-提前批-笔试/2021-8-2 shopee-提前批-笔试 .pdf differ diff --git a/笔试+面试题汇总/2021-8-2 shopee-提前批-笔试/数的划分.py b/笔试+面试题汇总/2021-8-2 shopee-提前批-笔试/数的划分.py new file mode 100644 index 0000000..f6d5d1a --- /dev/null +++ b/笔试+面试题汇总/2021-8-2 shopee-提前批-笔试/数的划分.py @@ -0,0 +1,23 @@ +# import lib +#https://blog.csdn.net/elma_tww/article/details/86538836 +# def functions +#dp[i][j]表示将整数i划分为j份的方案数 +#dp[i-j],拿出j个数,分别放上1,dp[i-j][2],2表示分为两份 +def divide(n,k,dp): + for i in range(1,n+1): + for j in range(1,k+1): + if i>=j:#划分的分数不能超过给定的整数 + dp[i][j]=dp[i-j][j]+dp[i-1][j-1]#裂项相消 + print(i,j,dp[i][j]) + return dp[n][k] + +#main +if __name__ == "__main__": + n,k = map(int,input().split(',')) + # n = int(n) + # k = int(k) + dp = [[0] *(k+1) for i in range(n+1)] + dp [0][0]=1 + #print(dp) + result = divide(n,k,dp) + print(result) \ No newline at end of file diff --git a/笔试+面试题汇总/2021-8-2 shopee-提前批-笔试/数组平衡点.py b/笔试+面试题汇总/2021-8-2 shopee-提前批-笔试/数组平衡点.py new file mode 100644 index 0000000..74bc654 --- /dev/null +++ b/笔试+面试题汇总/2021-8-2 shopee-提前批-笔试/数组平衡点.py @@ -0,0 +1,15 @@ +def findBalancedIndex(arr): + for temp in range(1,len(arr)): + # a=sum(arr[:temp]) + # print(a) + # b=sum(arr[temp+1:]) + # print(b) + if sum(arr[:temp])==sum(arr[temp+1:]): + #print(temp) + return temp +result1 = findBalancedIndex([1,2,3,4,6]) +result2 = findBalancedIndex([1,2,1]) +result3 = findBalancedIndex([1,2,2,2,1]) +print(result1) +print(result2) +print(result3) \ No newline at end of file diff --git a/笔试+面试题汇总/readme.md b/笔试+面试题汇总/readme.md new file mode 100644 index 0000000..be5bdc0 --- /dev/null +++ b/笔试+面试题汇总/readme.md @@ -0,0 +1 @@ +2021-8-2 shopee-提前批-笔试----jiet07 diff --git a/面试题汇总/readme.md b/面试题汇总/readme.md deleted file mode 100644 index 8b13789..0000000 --- a/面试题汇总/readme.md +++ /dev/null @@ -1 +0,0 @@ -