摘要: #include using namespace std; //大数的进制转换,实际上这是大数除正常数的除法的做法 string a; int b; string trans(){ string rt,aa=a; while(!aa.empty()){ cout>a>>b; cout<<trans()<<endl; } 阅读全文
posted @ 2020-06-06 21:32 西伯利亚挖土豆 阅读(187) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std; //见https://blog.csdn.net/sky980114/article/details/69038382 //观察发现从某一个节点到达另一个节点的路径期望值等于路径中所有可能被遍历的边数之和,因为深搜的特点导致了遍历完一整棵树才能走 // 准则2可以转化成准则1,因为准则2终点固定 int n,x[100001],y[10... 阅读全文
posted @ 2020-06-06 21:31 西伯利亚挖土豆 阅读(125) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std; //目标是判断因子个数是奇数还是偶数,可有不用求出因子个数,会超时 //方法是判断是不是完全平方数,如果是那么就是奇数个因子否则就是偶数个因子,因为因子成对存在; int main(){ long long x;//不知道为啥,用long long 就对了,int 不对 while (cin>>x&... 阅读全文
posted @ 2020-06-06 21:31 西伯利亚挖土豆 阅读(140) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include #include #include #include using namespace std; int x,y; int f1(){ int da=2,xx=y,i=2,count1=0; while (xx>1) { if(xx%i==0){ ... 阅读全文
posted @ 2020-06-06 21:31 西伯利亚挖土豆 阅读(164) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> using namespace std; const int maxn=310; int n,dp[maxn][maxn]={0},G[maxn][maxn],m,w[maxn],select[maxn][maxn]={0},b[maxn]={0},c[maxn]={0};//b兄弟,c孩子 //将森林多叉树转换成二叉树 int main() { 阅读全文
posted @ 2020-06-06 21:27 西伯利亚挖土豆 阅读(175) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cmath> #include <cctype> #include <algorithm> // #define DEBUG //可注释 #ifndef DEBUG #include <fstream> #define cout 阅读全文
posted @ 2020-06-06 21:26 西伯利亚挖土豆 阅读(122) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> using namespace std; //从0开始 //另一种方法构建表达式树,并通过表达式树进行表达式求值 //约定表达式都是合法的,且在一行内输入,并没有空格 //约定运算符有 + - * /(整除) ( ) //约定操作数都是一位正整数,没有负号 char s[100],ops[100];//ops是树的节点内容 int len=-1,l 阅读全文
posted @ 2020-06-06 21:26 西伯利亚挖土豆 阅读(318) 评论(0) 推荐(0) 编辑
摘要: // 我们将一棵树T = ( V,E )的直径定义为maxδ ( u,v ) ( u,v ∈ V ),也就是说,树中所有最短路径距离的最大值即为树的直径。 // 对于树的直径呢,我们老师给我们介绍了两种做法,一种是用两次bfs(或者dfs),另一种是用树形DP // 对于树的直径,两种做法,一种是用两次bfs(或者dfs),另一种是用树形DP // 两次dfs 先从任意一点P出发,找离它最远的点Q 阅读全文
posted @ 2020-06-06 21:26 西伯利亚挖土豆 阅读(120) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cctype> #include <sstream> #include <map> #define DEBUG #ifndef DEBUG #include <fstream> #define cout fff ofstream 阅读全文
posted @ 2020-06-06 21:24 西伯利亚挖土豆 阅读(102) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std; //mod值必须是素数 //做法不唯一,可以 //(1)通过循环,预先算好所有小于max_number的阶乘(%p)的结果,存到fac[max_number]里 (fac[i] = i!%p) //然后用求逆的方法求出结果 long long mod=31; long long pow_mod(int x,int y,int c){ ... 阅读全文
posted @ 2020-06-06 21:23 西伯利亚挖土豆 阅读(142) 评论(0) 推荐(0) 编辑