摘要: int jc[M]; int f[M]; int ksm(int a,int b){ int res=1; while(b){ if(b&1)res=res*a%mod; a=a*a%mod; b>>=1; }return res%mod; } int c(int a,int b){ return 阅读全文
posted @ 2025-12-03 23:22 Marinaco 阅读(4) 评论(0) 推荐(0)
摘要: void dfs1(){ // 求出重儿子 } void add(){ // 加入一个节点的贡献 } void del(){ // 删去一个节点的贡献 } void insert(int u){ // 加入整棵子树的贡献 add(u); for(int i=head[u],v;i;i=e[i].nx 阅读全文
posted @ 2025-12-03 13:00 Marinaco 阅读(2) 评论(0) 推荐(0)
摘要: int n,q; int tot; #define ls ch[rt][0] #define rs ch[rt][1] #define vl ch[vs][0] #define vr ch[vs][1] int rt[M]; int ch[M<<5][2]; int val[M<<5]; int a 阅读全文
posted @ 2025-12-02 12:26 Marinaco 阅读(5) 评论(0) 推荐(0)
摘要: int n,m; vector<pii>e[M]; int c[M]; int f[3005][3005]; void init(){ rep(i,0,3000) rep(j,0,3000) f[i][j]=-inf; } int dfs(int u){ if(u>n-m){ f[u][1]=c[u 阅读全文
posted @ 2025-12-02 11:11 Marinaco 阅读(4) 评论(0) 推荐(0)
摘要: void spfa(int s)//spfa跑最长路 { memset(dis, -1, sizeof(dis)); memset(V, 0, sizeof(V)); dis[s] = sum[s]; V[s] = 1; q.push(s); while (!q.empty()) { int u = 阅读全文
posted @ 2025-12-01 20:56 Marinaco 阅读(4) 评论(0) 推荐(0)
摘要: void exgcd(int &x,int &y,int a,int b) { if(!b) { x=1; y=0; return; } exgcd(x,y,b,a%b); int t=x; x=y; y=t-a/b*y; } void solve(){ //求解 ax+by =c 的不定方程 in 阅读全文
posted @ 2025-12-01 12:51 Marinaco 阅读(6) 评论(0) 推荐(0)
摘要: A int w,b; void solve(){ cin>>w>>b; w*=1000; cout<<w/b+1; } B int n,m; void solve(){ cin>>n>>m; map<int,int>mp; map<int,int>cnt; rep(i,1,n){ int a,b;c 阅读全文
posted @ 2025-11-30 09:55 Marinaco 阅读(8) 评论(0) 推荐(0)
摘要: int rt[M]; int cnt[M<<5]; int ch[M<<5][2]; int pre[M]; int tot=0; int n,m; void ins(int a,int b,int t,int x){ if(t<0)return; int i = (x>>t)&1; ch[a][! 阅读全文
posted @ 2025-11-25 21:37 Marinaco 阅读(5) 评论(0) 推荐(0)
摘要: ordered_multiset 由于set和multiset不支持随机访问,所以二分查询的速度是\(O(n)\)的 (你不可以使用st.lower_bound(value) -st.begin()这样的查询方法而是需要调用distance方法) ordered_multiset提供了方法order 阅读全文
posted @ 2025-11-25 11:42 Marinaco 阅读(7) 评论(0) 推荐(0)
摘要: #include <iostream> #include <vector> #include <numeric> #include <algorithm> #include <cmath> using namespace std; using ll = long long; const int MA 阅读全文
posted @ 2025-11-18 10:16 Marinaco 阅读(9) 评论(0) 推荐(0)
//雪花飘落效果