摘要: #include<bits/stdc++.h> using namespace std; const int N=100005; struct node { int u; int v; }a[N]; int color[N]; int e[N],h[2*N],nxt[2*N]; int idx=0; 阅读全文
posted @ 2026-11-16 19:27 zhangheyao 阅读(4) 评论(0) 推荐(0)
摘要: using namespace std; const int N=1e5+10; int c[N],a[N],ssumm[N]; int n; inline int lowbit(int x){ x=x&(-x); return x; } void add(int x,int y){ while(x 阅读全文
posted @ 2026-11-16 19:23 zhangheyao 阅读(3) 评论(0) 推荐(0)
摘要: 最大公约数 int gcd(int a,int b) { while(b!=0) { int t=b; b=a%b; a=t; } return a; } 最小公倍数 int lcm(int a,int b) { return (a/gcd(a,b))*b; } 阅读全文
posted @ 2026-02-02 14:33 zhangheyao 阅读(14) 评论(0) 推荐(0)
摘要: 01背包问题: 无优化 for(int i=1;i<=n;i++) { for(int c=0;c<=m;c++) { f[i][c]=f[i-1][c]; if(c>=w[i]) f[i][c]=max(f[i][c],f[i-1][c-w[i]]+v[i]); } } 一维数组优化: for(i 阅读全文
posted @ 2026-02-01 16:21 zhangheyao 阅读(21) 评论(0) 推荐(0)