摘要: 如果状态之间能够相互推出 注意排除冗余状态 //main:: f[0][1][1]=a[1][1]; for(int i=1;i<=(n+m-2);i++) for(int j=1;j<=n;j++) for(int k=1;k<=n;k++) if(i+2-j>0&&i+2-k>0) { int 阅读全文
posted @ 2022-02-08 13:55 __iostream 阅读(84) 评论(0) 推荐(0)
摘要: 照相过程中 给定每排的人数 要求后面比前面高 左边比右边高 后面一排比前边一排人多 求解总的方案数 f[0][0][0][0][0]=1; for(int i=1;i<=a[1];i++) for(int j=0;j<=min(i,a[2]);j++) for(int k=0;k<=min(j,a[ 阅读全文
posted @ 2022-02-08 13:54 __iostream 阅读(23) 评论(0) 推荐(0)
摘要: 我的想法: f[i][j]表示以i结尾的a与j结尾的b的最长公共子序列 状态转移方程 \[ f[i][j]=max\{f[k][l]\}+1 \] 时间复杂度:\(O(n^4)\) 我们要分析最长上升子序列,就必须分析最后一位,因此状态里要包含最后一位. 但是注意到这道题的特殊条件 a[i]和b[j 阅读全文
posted @ 2022-02-08 13:54 __iostream 阅读(38) 评论(0) 推荐(0)
摘要: 质因数分解n! for(int i=2;i<=n;i++) { if(vis[i]) continue; s[++tot]=i; for(int j=i;j<=n/i;j++) vis[i*j]=1; } for(int i=1;i<=tot;i++) { int p=s[i],sum=0,tmp= 阅读全文
posted @ 2022-02-08 10:50 __iostream 阅读(52) 评论(0) 推荐(0)
摘要: 1. 欧拉函数 p 为n的质因子 \[ \varphi(n)=n \times \Pi(1-\frac{1}{p}) \] 1~n中与n互质的数的和:\(\frac{n}{2}\times \varphi(n)\) 如果a,b互质,那么$\varphi(ab)=\varphi(a)\times\va 阅读全文
posted @ 2022-02-08 10:49 __iostream 阅读(61) 评论(0) 推荐(0)
摘要: L~R中质数距离最小最大值(R-L<=1e6) 思路过程: 注意到区间长度很小 我们考虑采用枚举区间长度的办法 \(O(L\sqrt R)\) 转化思路 用$\sqrt{n}$内 所有的倍数筛掉区间内的数 复杂度不便 注意到这样会有重复 那么我们用$\sqrt{n}$内所有质数筛一遍就可以 线性筛包 阅读全文
posted @ 2022-02-08 10:49 __iostream 阅读(45) 评论(0) 推荐(0)
摘要: 动态维护01序列中第k个1的位置 为了配合树状数组 采用枚举每一位的方式来构成长度 #include <iostream> #include <cstdio> #include <cstring> #include <cmath> using namespace std; const int N=1 阅读全文
posted @ 2022-02-08 10:37 __iostream 阅读(78) 评论(0) 推荐(0)
摘要: 1. 基本操作 运算 MATLAB 支持+ - * / 和^(次方运算) *,^ 支持矩阵乘法 dot(A,B) 点积 cross(A,B) 叉积 .* ./ .^ 代表对每个位置上的操作 inv(A) 矩阵求逆 变量定义 不需要定义变量类型 默认double A=10;(加分号表示不输出结果) A 阅读全文
posted @ 2022-02-04 18:36 __iostream 阅读(206) 评论(0) 推荐(0)
摘要: 挖坑 #include <iostream> #include <cstdio> #include <cstring> #include <set> #include <cmath> #include <vector> using namespace std; const int N=17; con 阅读全文
posted @ 2022-01-23 16:48 __iostream 阅读(59) 评论(0) 推荐(0)
摘要: 深度优先搜索 小木棍 int cnt=0; bool dfs(int len,int now,int used,int last)//枚举的长度 现在拼的长度 使用的棍棒数量 { if((used==n)&&(now==len)) return 1; if(now==len) { int fail= 阅读全文
posted @ 2022-01-21 20:41 __iostream 阅读(34) 评论(0) 推荐(0)