摘要: class Solution: def coinChange(self, coins: List[int], amount: int) -> int: dp = [float('inf')] * (amount + 1) dp[0] = 0 for coin in coins: for x in r 阅读全文
posted @ 2025-07-19 11:23 邓佑孤 阅读(4) 评论(0) 推荐(0)
摘要: 直觉认为,系统库中自带的幂函数性能优于快速幂 但是C++幂函数不支持模运算,因此在涉及到结果取模时,需要使用自定义的快速幂。 然而python没有这一问题,python中的pow可选择第三个参数,即mod,自带模运算的功能。 经实验,python自带pow确实优于快速幂,然而c++中的pow速度要比 阅读全文
posted @ 2025-06-18 21:52 邓佑孤 阅读(10) 评论(0) 推荐(0)
摘要: from functools import lru_cache @lru_cache(maxsize=None) # 加在函数定义前 def lcm(a, b): return (a * b) // math.gcd(a, b) 简单的缓存 import time def timer(func): 阅读全文
posted @ 2025-06-18 21:24 邓佑孤 阅读(6) 评论(0) 推荐(0)
摘要: #include<bits/stdc++.h> using namespace std; int n; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int lcm(int a, int b) { return (a / g 阅读全文
posted @ 2025-06-18 20:27 邓佑孤 阅读(36) 评论(0) 推荐(0)
摘要: 蓝桥杯国赛 from math import sqrt inf = float('inf') n, mx = map(int,input().split()) dot=[] for i in range(n): x,y=map(int,input().split()) dot.append((x,y 阅读全文
posted @ 2025-05-25 15:45 邓佑孤 阅读(6) 评论(0) 推荐(0)
摘要: #include<bits/stdc++.h> using namespace std; int main() { int a[6]={1,2,2,3,4,5}; //方法一 vector<int>b(a,a+6);//使用unique需保证已经排好序 b.erase(unique(b.begin( 阅读全文
posted @ 2025-05-18 16:44 邓佑孤 阅读(7) 评论(0) 推荐(0)
摘要: 两种自定义优先级方式 struct node { int ind;double l; bool operator<(const node& other) const { return l < other.l; } }; priority_queue<node>pq; struct cmp { boo 阅读全文
posted @ 2025-05-10 19:42 邓佑孤 阅读(6) 评论(0) 推荐(0)
摘要: #include<bits/stdc++.h> #pragma GCC optimize(2) #define ll long long using namespace std; ll n,m;ll a[1000001];ll tree[1000001];ll tag[1000001]; int t 阅读全文
posted @ 2025-04-08 21:41 邓佑孤 阅读(19) 评论(0) 推荐(0)
摘要: 吊坠 import os import sys from collections import defaultdict # 请在此输入您的代码 n,m=map(int,input().split()) l=[] cnt=0 for i in range(n): a=input() a=a+a d=d 阅读全文
posted @ 2025-04-05 19:18 邓佑孤 阅读(7) 评论(0) 推荐(0)
摘要: 洛谷单调队列模板 n,k=map(int,input().split()) l=list(map(int,input().split())) def sld(m,k): max_r=[] max_q=[] min_r=[] min_q=[] for i,num in enumerate(m): wh 阅读全文
posted @ 2025-04-01 20:52 邓佑孤 阅读(18) 评论(0) 推荐(0)