CARLJOSEPHLEE
CARLJOSEPHLEE
全部文章
分类
题解(26)
归档
标签
去牛客网
登录
/
注册
CARLJOSEPHLEE的博客
全部文章
(共216篇)
题解 | 小红的字符串修改
我还以为是力扣那个经典的编辑距离,结果是个暴力枚举 s1 = [ord(i) for i in input().strip()] s2 = [ord(i) for i in input().strip()] n1,n2 = len(s1),len(s2) tempmin = 9999999999 f...
2025-07-13
3
53
题解 | 穷哈哈~
好久没写模拟题,WA了好多发qwq from sys import stdin read1 = stdin.read().split() n = int(read1[0]) str1 = read1[1] index = 0 tempmax = 0 pre = None templen = 0 wh...
2025-07-13
0
41
题解 | 买橘子
懒得滚动数组优化了 n = int(input()) dp = [999999]*(n+100) dp[6] = dp[8] = 1 for i in range(9,n+1): dp[i] = min(dp[i-6],dp[i-8]) if dp[i] != 999999: ...
2025-07-13
1
32
题解 | 田忌赛马
有趣的思维题,排序后遍历一遍田忌的马即可,贪心算法,始终让刚好能跑赢齐王的马上场:) l1 = list(sorted(list(map(int,input().split())))) l2 = list(sorted(list(map(int,input().split())))) cnt = 0...
2025-07-13
10
122
题解 | 小红喜欢1
l = [int(i) for i in input().split()] index = 0 while l[index] != 1: index += 1 print(index+1)
2025-07-13
1
30
题解 | 称砝码
n = int(input()) weights = [int(i) for i in input().split()] nums = [int(i) for i in input().split()] set1 = set() set1.add(0) for i in range(n): ...
2025-03-11
0
256
题解 | 汽水瓶
while 1: n = int(input()) if n == 0: break cnt = 0 while n >= 3: cnt += n//3 n = n%3+n//3 if n == 2: ...
2025-03-11
0
215
题解 | 走方格的方案数
n,m = map(int,input().split()) n += 1 m += 1 dp = [[0]*(m+1) for _ in range(n+1)] for i in range(1,n+1): dp[i][1] = 1 for j in range(1,m+1): d...
2025-03-11
0
195
题解 | 统计字符
a = input() n = len(a) cnt1,cnt2,cnt3,cnt4=0,0,0,0 for i in range(n): temp = ord(a[i]) if 65<=temp<=90 or 97<=temp<=122: c...
2025-03-11
0
193
题解 | 统计每个月兔子的总数
n = int(input()) def f(x): a,b = 1,1 for _ in range(x): a,b = a+b,a return b print(f(n-1))
2025-03-11
0
182
首页
上一页
10
11
12
13
14
15
16
17
18
19
下一页
末页