- 博客(16)
- 收藏
- 关注
原创 PAT A 1021. Deepest Root
1021. Deepest Root (25)P 判断连通:并查集.找最长的根,两步DFS.第一个DFS从一个点出发,找到里这个点最远的点集合,这个在ANS里面.第二部从ANS里任意找个点,再DFS.又找到最远的点集.两个点集的并集,就是ANS.不要问我为什么,我也不知道.#include <bits/stdc++.h> using namespace std; struct UnionFind {
2017-01-28 13:54:42 250
原创 PAT A 1118. Birds in Forest
PAT A 1118. Birds in Forest (25) https://www.patest.cn/contests/pat-a-practise/1118 裸并查集#include <bits/stdc++.h> using namespace std; struct UnionFind { vector<int> id, sz; int n, cnt; U
2017-01-23 10:15:49 337
原创 PAT A 1117. Eddington Number
PAT A 1117. Eddington Number https://www.patest.cn/contests/pat-a-practise/1117首先题目意思就难懂,就是N个数,找一个数E,使得这N个数里面有E个数比E大 特别注意是大,相等不行 知道了这个 首先排序咯 然后找就好了#include <bits/stdc++.h> using namespace std;
2017-01-23 09:39:52 821
原创 PAT 1116. Come on! Let's C
PAT 1116. Come on! Let’s C (20) https://www.patest.cn/contests/pat-a-practise/1116#include <bits/stdc++.h> using namespace std; bool isPrime(int x) { if (x < 2) return false; for (int i = 2; i
2017-01-23 08:57:55 549
原创 2016 China-Final A. Number Theory Problem
http://codeforces.com/gym/101194 只有2^3 - 1可以#include <bits/stdc++.h> using namespace std; int main() { int T; scanf("%d", &T); for (int i = 1; i <= T; i++) { int N; scanf(
2017-01-23 07:30:12 357
原创 Codeforces Round #392 (Div. 2) B. Blown Garland
CF 758/problem/B http://codeforces.com/contest/758/problem/B 英语一定要学好,题目都看错,做毛线题?! 这道题提议是有N个灯泡,按顺序, 再说一遍,按顺序,但是不知道是什么顺序 一旦确定,就是4个一循环4个一循环的那种 现在爆炸了M个,用!表示,问你那种颜色爆炸了哪几个?这样先扫一遍就确定位置了. 再扫一遍就可以确定爆炸是那些
2017-01-22 17:16:39 298
原创 蓝桥杯 T32大臣的旅费
蓝桥杯 T32大臣的旅费http://lx.lanqiao.cn/problem.page?gpid=T32 历届试题 大臣的旅费 时间限制:1.0s 内存限制:256.0MB 提交此题 锦囊1 锦囊2 问题描述 很久以前,T王国空前繁荣。为了更好地管理国家,王国修建了大量的快速路,用于连接首都和王国内的各大城市。 为节省经费,T国的大臣们经过思考,制定
2017-01-19 20:30:39 391
原创 PAT A 1093. Count PAT's (25)
问一个字符串中有几个子序列是PAT?从后往前.先找T.T++.找到A.A+=T.说明已经找到了A个AT了.最后找到P.+=A.更新ANS就好#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 1000000007; int main() { string s; cin >
2017-01-19 08:09:26 257
原创 PAT A 1015. Reversible Primes
PAT A 1015. Reversible Primes给一个10进制数 转成D进制 取倒序 再转成10进制 看两个是否都是质数 坑点在于 1不是质数 不考虑这个就有2分得不到#include <bits/stdc++.h> using namespace std; bool isPrime(int x) { if (x <= 1) return false; for
2017-01-18 22:00:25 336
原创 PAT A 1013. Battle Over Cities
PAT A 1013. Battle Over Cities就是并查集 id[x] = fd(id[x]) 写成 id[x] = fd(x) 导致段错误 ZZ#include <bits/stdc++.h> using namespace std; struct UnionFind { vector<int> id; vector<int> sz; int n;
2017-01-18 16:54:46 318
原创 PAT A 1012. The Best Rank
PAT A 1012. The Best Rank坑点在于同分同名次,后面的名次又加回去 i.e. 1 1 3 3 3 6 这种情况#include <bits/stdc++.h> using namespace std; struct V { string s; int a[10]; //A C M E void read() { cin >> s
2017-01-18 09:18:02 349
原创 PAT A 1011. World Cup Betting
1011. World Cup Betting (20)套公式算就好#include <bits/stdc++.h> using namespace std; int main() { double s = 1; for (int i = 0; i < 3; i++) { double t = 0; int maxj = 0; for
2017-01-18 07:30:44 256
原创 PAT A 1011. World Cup Betting
1011. World Cup Betting (20)套公式算就好#include <bits/stdc++.h> using namespace std; int main() { double s = 1; for (int i = 0; i < 3; i++) { double t = 0; int maxj = 0; for
2017-01-18 07:30:14 217
原创 PAT A 1009. Product of Polynomials
PAT A 1009. Product of Polynomials (25) 1WA 系数为0不能算 2WA 虽然系数为0不算还是算在了K里面 3WA 智障 样例都没过就交了 可能有多种组合达到相同次数 用+= 而不是 =#include <bits/stdc++.h> using namespace std; typedef pair<int, double> Pair; const do
2017-01-15 19:41:18 333
原创 AVL Tree(1)
AVL Tree参考: [1]http://www.geeksforgeeks.org/avl-tree-set-1-insertion/ [2]https://www.cyut.edu.tw/~ckhung/b/al/balst.php一.二叉搜索树对任意一个节点 左边的全部节点都比这个节点小 右边的全部节点都比这个节点大 这样要找一个数 就只要比较和当前节点的大小 然后选择在左子树
2017-01-15 17:41:07 389
原创 POJ 1159 Palindrome
1月2日,一天一题Description给一个字符串,问再加多少个能变成会问Algorithm和这个字符串的逆串求一个LCS n - LCS就是答案Hint本题直接开二维数组要爆炸,用short或者滚动数组来做,滚动数组还需研究Code//#include <bits/stdc++.h> #include <cstdio> #include <cstring> #include <iostream
2017-01-02 11:11:13 502
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人