360 24号,两题100,AC代码

第一题基本暴力解,注意不是所有的字母都是对称的就可以
第二题注意首先没有宝物的关卡先过完,然后注意有宝物的关卡使用宝物的时机是,该关卡的分数大于之前所有关卡的分数的和
代码如下:
# 第一题
sameLetters = ['A', 'H', 'I', 'M', 'O', 'T', 'U', 'V', 'W', 'X', 'Y']

while True:
    _str = input()
    if len(_str)<=0:
        break
    half = len(_str) // 2 +1
    lenght = len(_str)

    #print(half, lenght)
    isYes = True
    for i in range(half):
        if not (_str[i] == _str[lenght - i-1] and _str[i] in sameLetters):
            isYes = False
            break
    if isYes:
        print("YES")
    else:
        print("NO")
#第二题
import numpy as np
k = int(input())
scores = 0
listb0 = []
listb1 = []
for i in range(k):
    a, b = map(int, input().split())
    if b == 0:
        listb0.append(a)
    else:
        listb1.append(a)
npb0 = np.array(sorted(listb0, reverse=True))
npb1 = np.array(sorted(listb1, reverse=True))

score0 = sum(npb0)
indexnpb1 = 0
for i in range(len(npb1)):
    if score0 < npb1[i]:
        score0 += npb1[i]
    else:
        indexnpb1 = i
        break
#print(score0)
#print(len(npb1[indexnpb1: ]))
score1 = 2**(len(npb1[indexnpb1:]))
scores = score0 * score1
print(scores)



#笔试题目##360公司#
全部评论

相关推荐

屌丝逆袭咸鱼计划:心态摆好,man,晚点找早点找到最后都是为了提升自己好进正职,努力提升自己才是最关键的😤难道说现在找不到找的太晚了就炸了可以鸡鸡了吗😤早实习晚实习不都是为了以后多积累,大四学长有的秋招进的也不妨碍有的春招进,人生就这样
点赞 评论 收藏
分享
05-09 14:45
门头沟学院 Java
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
06-24 14:18
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务