何成HN
何成HN
全部文章
分类
归档
标签
去牛客网
登录
/
注册
何成HN的博客
全部文章
(共439篇)
题解 | 小红的字符串
s = input() ans, n, l, r = 0, len(s), 0, len(s)-1 while l < r:#采用双指针法,两端指针向内靠拢 dis = abs(ord(s[l]) - ord(s[r])) ans += min(dis, 26 - dis)#寻...
2025-08-27
0
32
题解 | 清楚姐姐买竹鼠
a, b, x = map(int, input().split()) if b / 3 >= a:#购买三只比单独购买一只无优惠,甚至价格更贵时 print(a * x) elif b <= a:#购买三只的价格不超过购买一只时 if x % 3 == 0:#需要购买的...
2025-08-27
0
47
题解 | 讨厌鬼进货
n, x = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) fee = 0 for i in range(n):#寻找购买第i件商品的最低价 fee...
2025-08-27
0
26
题解 | 小红的优惠券
n, m = map(int,input().split()) coupon = [list(map(int,input().split())) for _ in range(m)]#输入存储优惠券 minfee = n#存储最少需要支付的费用 for a,b in coupon:#遍历整个优惠券列...
2025-08-27
0
47
题解 | 小红背单词
n = int(input()) words = []#已经记住的单词 dic = dict()#要记得单词,以及背的次数 for i in range(n): word = input() dic[word] = dic.setdefault(word,0)+1#将当前背的单词,背...
2025-08-27
0
37
题解 | 宝石手串
t = int(input()) for _ in range(t): n = int(input()) s = input() if len(set(s)) == n:#手串中没有相同的宝石,无法破环,返回-1 print(-1) conti...
2025-08-27
0
39
题解 | 预知
t = int(input())#测试数据组数 for _ in range(t): n = int(input())#当前组测试数据包含的卡牌种类,n种卡牌 cards = list(map(int,input().split()))#n种卡牌每种包含的卡牌数量 if n=...
2025-08-27
0
32
题解 | 支付宝消费打折
n, k = map(int,input().split()) a = list(map(int,input().split())) s = input() aa = sorted([a[i]*0.95 if s[i]=='1' else a[i] for i in range(n)])#折扣后的升...
2025-08-26
0
54
题解 | 【模板】排序
n = int(input())#输入元素个数 ns = list(map(int,input().split()))#输入元素列表 ns.sort()#对元素列表进行升序排列 print(' '.join(map(str,ns)))#对排列后的元素列表进行拼接输出
2025-08-26
0
49
题解 | 分数线划定
n, m = map(int,input().split())#输入n,m ks = [list(map(int,input().split())) for _ in range(n)]#输入报名号和成绩 ks.sort(key=lambda x:(-x[1],x[0]))#成绩降序,报名号升序排列...
2025-08-26
0
43
首页
上一页
31
32
33
34
35
36
37
38
39
40
下一页
末页