京东算法0分代码
# 01比 0% n = int(input()) zi = input() ans = [1] * n for i in range(0, n, 2): if i != 0 and '1' not in zi[0:i+1]: ans[i] = i+1 if i != 0 and '0' not in zi[0:i+1]: ans[i] = i+1 for i in range(1, n, 2): ans1 = 0 for j in zi[0:i+1]: if j == '1': ans1 += 1 ans[i] = ans1 print(ans)
# 吃竹子 36% n, a, b, c = list(map(int, input().split())) zhuzi = [a, b, c] zhuzi.sort() dp = [0] * (n + 1) for j in range(1, n + 1): if j < zhuzi[0]: dp[j] = 0 elif zhuzi[0] <= j < zhuzi[1]: dp[j] = 1 + dp[j - zhuzi[0]] elif zhuzi[1] <= j < zhuzi[2]: dp[j] = max(1 + dp[j - zhuzi[0]], 1 + dp[j - zhuzi[1]]) else: dp[j] = max(1 + dp[j - zhuzi[0]], 1 + dp[j - zhuzi[1]], 1 + dp[j - zhuzi[2]]) print(dp[-1])
#京东笔试##笔试题目#