摘要: #include using namespace std; int main(){ string s[32]; int num,truth,a[5],flg=0,pq=0; int b[5];//做没做 char c; cin>>num>>c>>truth; for(b[0]=0;b[0]0) a[1]=1; else a[1]=... 阅读全文
posted @ 2020-06-06 21:22 西伯利亚挖土豆 阅读(132) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std; //无关的元素.png //算法入门经典 // 组合数Cmn很大,很有可能溢出,真的非常大,类似于n!,即使longlong也存不下 // 在这种情况下 可以考虑 用组合数递推公式,这样从1开始每次对(n-k+1)/k进行素因子分解然后累加, //就得到了每个的分解结果,但是要注意(n-k+1)/k可能 yinzi;//m的素因子及其... 阅读全文
posted @ 2020-06-06 21:22 西伯利亚挖土豆 阅读(158) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include #include // #include "debug.h" using namespace std; //浮点数陷阱比较时必须用绝对值abs,因为是比较是否在误差内相等。 struct X{ char name; long long x,y; X(char name,... 阅读全文
posted @ 2020-06-06 21:20 西伯利亚挖土豆 阅读(123) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std; //利用快速排序的思路,每次都有选择的在左边或右边递归。 //[,] // int a[6]={1,2,2,3,5,5}; int a[6]={2,1,2,5,3,5}; int nth(int n,int x,int y){ int i=x,j=y; while(i=a[i]) j--; if(i<j... 阅读全文
posted @ 2020-06-06 21:19 西伯利亚挖土豆 阅读(140) 评论(0) 推荐(0) 编辑
摘要: #include<bits/stdc++.h> using namespace std; long long facc[1000001]={0},fac[1000001]={0},inv[1000001]={0}; long long mod=1000000007; long long pow_mod(int x,int y,int c){ if(y==0) return 1; long long 阅读全文
posted @ 2020-06-06 21:16 西伯利亚挖土豆 阅读(202) 评论(0) 推荐(0) 编辑
摘要: #include<bits/stdc++.h> using namespace std; //背包问题求限制条件的方案数,求装满的前提下的方案数(不是最优解也可) //这个题等价于求完全背包的方案数,dp数组表示装满的方案数目,只包括装满了的,这取决于初始值, //如果dp数组表示总方案数,包括没装满的,那么初始值不同 //数组太大使用滚动数组+完全背包的优化 //dp[i][j]=dp[i][j 阅读全文
posted @ 2020-06-06 21:15 西伯利亚挖土豆 阅读(179) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> using namespace std; int tree[100001],dp[100001],p[100001],n,x,y,mask[100001]={0},sons[100001]={0}; int rdp1[100001],rdp2[100001]={0},vis[100001]={0}; //树形dp,从下往上更新,具体见算法入门经典 阅读全文
posted @ 2020-06-06 21:15 西伯利亚挖土豆 阅读(267) 评论(0) 推荐(0) 编辑
摘要: //对子树进行考虑,都有派m个回n个的可能,但是有冗余 //对于去一个回一个,去m个回m个,第二种肯定耗费多。因为去一个回一个类比dfs每一条边走两次即可(这也是最小的情况),而好几个机器人, //每一条边走两次 ,而且至少+去子树、回子树,(每个机器人独立计算),所以要回来就只派一个 //同样,如果对一棵子树部分机器人返回,部分不返回,则这种情况一定没有仅仅只用不返回的部分遍历整棵子树且不返回小 阅读全文
posted @ 2020-06-06 21:14 西伯利亚挖土豆 阅读(183) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std; //二叉苹果树 //j代表保留树枝的总数 //做法一:当j大于子树所能保存的最大的边的时候,值都是最大的边对应的值,导致肯定没有刚好分配边数的值大 int n,dp[110][110]={0},G[100+10][100+10],k,sons[100+10]={0}; void dfs(int rt,int f){ int l... 阅读全文
posted @ 2020-06-06 21:12 西伯利亚挖土豆 阅读(157) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std; //加分二叉树 int n,dp[40][40]={0},a[40],ans=0,root[40][40]; void f(int i,int j){ if(i>j) return; cout>n; for(int i=1;i>a[i]; for(int l=1;l=dp[i][j-1]+a[j]){ ... 阅读全文
posted @ 2020-06-06 21:11 西伯利亚挖土豆 阅读(143) 评论(0) 推荐(0) 编辑