派仔
派仔
全部文章
分类
题解(68)
归档
标签
去牛客网
登录
/
注册
Lincs
Do more, know more, be more
全部文章
(共149篇)
题解 | #矩阵乘法计算量估算#
n = int(input()) a = [0] * n b = [0] * n for i in range(n): a[i], b[i] = map(int, input().split(" ")) s = input() ans = 0 stack = [] for ch in ...
2023-04-12
1
290
题解 | #求解立方根#
val = float(input()) # 这里的1.0设置还挺巧妙 l, r = min(-1.0, val), max(1.0, val) # 用区间大小进行判断 while r - l > 0.001: m = l + (r - l) / 2 if m ** 3 &...
2023-04-10
1
245
题解 | #挑7#
n = int(input()) cnt = 0 for i in range(1, n+1): if i % 7 == 0: cnt += 1 elif '7' in str(i): cnt += 1 print(cnt)
2023-04-10
1
257
题解 | #计算字符串的编辑距离#
while True: try: a = input() b = input() n, m = len(a) + 1, len(b) + 1 dp = [[0] * m for _ in range(n)] # ...
2023-04-09
1
266
题解 | #24点游戏算法#
import sys ops = ["+", "-", "*", "/"] # 从四个数中任意挑俩数,计算结果放回去,变成仨数 # 从三个数中任意挑俩数,计算结果放回去,变成俩数 # 最后俩数执行运算 def cal(a, b, op): if op == "+": ret...
2023-04-08
1
351
题解 | #MP3光标位置#
n = int(input()) s = input() idx = 0 song = 0 for ch in s: if ch == 'U': if idx > 0 or idx == 0 and song == 0: idx = (idx...
2023-04-08
1
310
题解 | #DNA序列#
这代码里还是很多坑的 s = input() n = int(input()) idx, cnt, max_cnt = 0, 0, 0 for i, ch in enumerate(s): if i >= n and (s[i-n] == 'C' or s[i-n] == 'G'):...
2023-04-07
1
323
题解 | #查找两个字符串a,b中的最长公共子串#
状态转移方程a[i] == b[i], dp[i][j] = dp[i-1][j-1],dp表示以a[i]结尾的字串和以b[j]结尾的字串的最长公共子串 a = input() b = input() # 确保a就是较短串 if len(a) > len(b): a, b = b, ...
2023-04-07
1
329
题解 | #称砝码#
n = int(input()) m = list(map(int, input().strip().split(" "))) x = list(map(int, input().strip().split(" "))) s = set() s.add(0) for i in range(n):...
2023-04-06
1
299
题解 | #求小球落地5次后所经历的路程和第5次反弹的高度#
n = int(input()) sum = 0 for i in range(5): sum += n n /= 2 sum += n sum -= n print("{:.6f}\n{:.6f}".format(sum, n))
2023-04-06
1
259
首页
上一页
1
2
3
4
5
6
7
8
9
10
下一页
末页