HDU1829(带权并查) #include<cstdio>#include<iostream>#include<cstring>#include<algorithm>using namespace std;const int maxn=2010;int fa[maxn];int sex[maxn];int n,m;int flag;void init()...
HDU1215(水) #include<cstdio>#include<iostream>using namespace std;const int maxn=1e5+10;int main(){ int t; int n; scanf("%d",&t); while(t--) { scanf("%d",&n); int ans=0; for(i...
hdu1108(水GCD) #include<cstdio>#include<iostream>using namespace std;int gcd(int a,int b){ return b==0?a:gcd(b,a%b);}int main(){ int n,m; while(scanf("%d%d",&n,&m)!=EOF) { int g=gcd...
hdu1084(水 结构体排序) #include<cstdio>#include<iostream>#include<string.h>#include<algorithm> using namespace std;const int maxn=10010;struct node{ int num; int time; int score; int id; ...
HDU1236结构体排序(水) #include<cstdio>#include<iostream>#include<algorithm>#include<string.h>using namespace std;struct node{ char num[100]; int s;}stu[1010];int score[110];int cnt;bool ...
HDU1597二分查找(水) #include<cstdio>#include<iostream>#include<string.h>using namespace std;typedef long long ll;int k;ll n;ll s[100000];int result;void search(int l,int r){ int mid=(l+r)/2...
HDU2504(水)GCD #include<cstdio>#include<iostream>using namespace std;int gcd(int a,int b){ return b==0?a:gcd(b,a%b);}int main(){ int c; int n; int a,b; scanf("%d",&n); while(n--) { s...
kuangbin N - Find a way (水bfs) Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. Leave Ningbo one year, yifenfei have many people to meet. Especially a good friend Merceki. Yifenfei’s home is at the co...
C. Reorder the Array(cf 水STL) C. Reorder the Arraytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an array of integers. Vasya can permute (chang...
cfC. Cut 'em all!(深搜) C. Cut 'em all!time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou're given a tree with nn vertices.Your task is to determine the maximum possible ...
cf 300 C(水) C. Tourist's Notestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA tourist hiked along the mountain range. The hike lasted for n days, during eac...
cfMahmoud and Ehab and the message(水map) B. Mahmoud and Ehab and the messagetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMahmoud wants to send a message to his friend Ehab. Their langu...
算法训练 单词接龙(dfs) 算法训练 单词接龙 时间限制:1.0s 内存限制:256.0MB 问题描述 单词接龙是一个与我们经常玩的成语接龙相类似的游戏,现在我们已知一组单词,且给定一个开头的字母,要求出以这个字母开头的最长的“龙”(每个单词都最多在“龙”中出现两次),在两个单词相连时,其重合部分合为一部分,例如 beast和astonish,如果接成一条龙则变为beastonish,另外相邻的两部分...
cfB. Our Tanya is Crying Out Loud B. Our Tanya is Crying Out Loudtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputRight now she actually isn't. But she will be, if you don't solve th...
算法训练 According to Bartjens (暴力水) 算法训练 According to Bartjens 时间限制:1.0s 内存限制:512.0MB 问题描述 计算器和计算机的大量普及也有其弊端。即便是受过专业技术训练的学生们也很可能缺乏计算能力。由于电脑的大量使用,很多人无法心算出7*8这样的算式,甚至是用纸和笔也算不出13*17。不过谁在意呢? Bartjens教授十分在意——因为他比较传统。他决定给学生布置一些计算作业,并...
基础练习 矩形面积交 (水) 基础练习 矩形面积交 时间限制:1.0s 内存限制:512.0MB 问题描述 平面上有两个矩形,它们的边平行于直角坐标系的X轴或Y轴。对于每个矩形,我们给出它的一对相对顶点的坐标,请你编程算出两个矩形的交的面积。输入格式 输入仅包含两行,每行描述一个矩形。 在每行中,给出矩形的一对相对顶点的坐标,每个点的坐标都用两个绝对值不超过10^7的实数表示。输出格式 输出仅包含一...
基础练习 完美的代价 基础练习 完美的代价 时间限制:1.0s 内存限制:512.0MB 问题描述 回文串,是一种特殊的字符串,它从左往右读和从右往左读是一样的。小龙龙认为回文串才是完美的。现在给你一个串,它不一定是回文的,请你计算最少的交换次数使得该串变成一个完美的回文串。 交换的定义是:交换两个相邻的字符 例如mamad 第一次交换 ad : mamda 第二次交换 md : madm...
蓝桥杯 数的读法(分类模拟) 基础练习 数的读法 时间限制:1.0s 内存限制:512.0MB 问题描述 Tom教授正在给研究生讲授一门关于基因的课程,有一件事情让他颇为头疼:一条染色体上有成千上万个碱基对,它们从0开始编号,到几百万,几千万,甚至上亿。 比如说,在对学生讲解第1234567009号位置上的碱基时,光看着数字是很难准确的念出来的。 所以,他迫切地需要一个系统,然后当他输入12 3456...
蓝桥杯 基础练习 芯片测试 问题描述 有n(2≤n≤20)块芯片,有好有坏,已知好芯片比坏芯片多。 每个芯片都能用来测试其他芯片。用好芯片测试其他芯片时,能正确给出被测试芯片是好还是坏。而用坏芯片测试其他芯片时,会随机给出好或是坏的测试结果(即此结果与被测试芯片实际的好坏无关)。 给出所有芯片的测试结果,问哪些芯片是好芯片。输入格式 输入数据第一行为一个整数n,表示芯片个数。 第二行到第n+1行为n*n的一张表,每...
cfB. XK Segments(二分) B. XK Segmentstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhile Vasya finished eating his piece of pizz