何成HN
何成HN
全部文章
分类
归档
标签
去牛客网
登录
/
注册
何成HN的博客
全部文章
(共409篇)
题解 | 小美的外卖订单编号
q = int(input()) for _ in range(q): m, x = map(int,input().split()) q, r = divmod(x,m) if r==0: print(m) else: print(r...
2025-11-25
0
28
题解 | Poi 的新加法(Easy Version)
t = int(input()) for _ in range(t): n, q = map(int,input().split()) a = list(map(int,input().split())) lr = [list(map(int,input().split())...
2025-11-25
0
22
题解 | 最长异或公共子段
t = int(input()) for _ in range(t): x, y = map(int,input().split()) ans = ((x^y)&(-(x^y))) print(ans)
2025-11-25
0
22
题解 | 【模板】01背包
n, v = map(int,input().split()) goods = [list(map(int,input().split())) for _ in range(n)] # --- 方案一:不要求装满 --- dp1 = [0]*(v+1) for u,w in goods:#决定每件物...
2025-11-24
0
23
题解 | 【模板】二维差分
def insert(diff, x1, y1, x2, y2, c): diff[x1][y1] += c diff[x2 + 1][y1] -= c diff[x1][y2 + 1] -= c diff[x2 + 1][y2 + 1] += c n, m, q...
2025-11-24
0
18
题解 | 【模板】二维差分
n, m, q = map(int,input().split()) # 差分矩阵, 大小设为 (n+2)x(m+2) d = [[0]*(m+2) for _ in range(n+2)] a = [[0]*(m+1) for _ in range(n+1)] # 1. 构建初始差分矩阵 for...
2025-11-24
0
19
题解 | 空间跃迁
n, k = map(int,input().split()) times = [0]+list(map(int,input().split()))#基于输入时长列表,定义初始前缀和列表 for i in range(1,n):#初始化构造前缀和列表 times[i] = times[i]+...
2025-11-24
0
23
题解 | 【模板】二维前缀和
n, m, q = map(int,input().split()) #用画图求面积的方式,能够直观的体现算法 s = [[0]*(m+1) for _ in range(n+1)]#定义空白二位前缀和矩阵 for i in range(1,n+1):#初始化二位前缀和矩阵 row = li...
2025-11-24
0
26
题解 | 植树节
n = int(input()) dp = [0]*1000002#定义差量数组,比10^6大2 max_i = 0#最大右下标 for _ in range(n):#初始化差量数组 a, b = map(int,input().split()) dp[a] += 1 dp...
2025-11-13
0
23
题解 | 牛牛与切割机
n = int(input()) a = list(map(int, input().split())) sum_total = sum(a)#列表中数字总和 sum_left = 0#左边列表数字和 min_mul = float("inf")#最小切割代价 for i in...
2025-11-13
0
26
首页
上一页
15
16
17
18
19
20
21
22
23
24
下一页
末页