招行 笔试题目

求第三题代码~~~~!

第一题
import math
n = int(input())
m = int(input())
l = []
for i in range(n):
l.append(int(input()))
print(max(max(l),math.ceil((sum(l)+m)/n)) ,max(l)+m)

第二题
n = int(input())
if n < 6:
print(0)
else:
print(2**(n-6)%666666666)
#笔试题目##招商银行#
全部评论
第三题是不是测试用例有错
点赞 回复 分享
发布于 2019-04-09 21:12
def cal(lis):    from functools import reduce    max_num = max(lis)    length = len(lis)    res = []    dic = {}    ddd = {}    for i in range(length):       dic = find(lis[i],max_num)       res.append(dic)    final_dic = reduce(merge,res)    keys = list(final_dic.keys())    for key in keys:       ddd[key] = 0       for di in res:          ddd[key] += di[key]    res = min(ddd.items(), key=lambda x: x[1])[1]    return res def merge(a,b):    from collections import Counter    return dict.fromkeys(x for x in a if x in b)    #return dict(Counter(x)+Counter(y)) def find(num,max_num):    res = {}    temp = num    count = 0    while num >= 1:       try:          v = res[num]       except:          res[num] = count       num = num // 2       count += 1    count = 0    while temp <= max_num:       try:          v = res[temp]       except:          res[temp] = count       count += 1       temp *= 2    return res if __name__ == '__main__':    n = int(input())    x = input().split(' ')    lis = list(map(int,x))    res = cal(lis)    print(res)
点赞 回复 分享
发布于 2019-04-09 21:15
请问是算法岗吗
点赞 回复 分享
发布于 2019-04-09 21:09
第二题过不了吧,我这么写只有50
点赞 回复 分享
发布于 2019-04-09 21:13
第一题为什么最小的k是max(max(l))
点赞 回复 分享
发布于 2019-04-09 21:29
题主你好,关于巧克力那题,总的可取方法为什么是2的(n-6)次方呢🤣,脑子有点没转过来😳
点赞 回复 分享
发布于 2019-04-09 21:35
那个第三题好像是acm原题这里有解题链接,我也是只过了两个,,,https://blog.csdn.net/fenghoumilin/article/details/60468759
点赞 回复 分享
发布于 2019-04-10 08:20
笔试原题谁能发一下吗,我没做
点赞 回复 分享
发布于 2019-04-10 10:13

相关推荐

MingoTree:看不出你你的技术栈,想找什么工作,然后课设项目别写上去了,自我评价删了,前后端你想好你要干啥,这种简历投上去秒挂的
点赞 评论 收藏
分享
评论
点赞
11
分享

创作者周榜

更多
牛客网
牛客企业服务