
UVA-LA算法题目
文章平均质量分 71
刘汝佳算法竞赛入门等书的习题
sortmin
这个作者很懒,什么都没留下…
展开
-
UVa - 712 - S-Trees
712 - S-Trees题解:统计每一层节点,每遇到1就增加当前区间的一半路程即可。AC代码:#include#include#include#include#includeusing namespace std;#define _for(i,a,b) for(int i=(a);i<=(b);i++)const int maxn = 130;int n,原创 2018-02-06 23:32:41 · 234 阅读 · 0 评论 -
LA - 3644 - X-Plosives
LA3644 - X-Plosives题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1645题意:有N种简单化...原创 2018-05-13 04:12:18 · 255 阅读 · 0 评论 -
Slim Span UVA - 1395(并查集)
Slim Span UVA - 1395 题目链接:https://vjudge.net/problem/UVA-1395 题意:给定n个节点的图,求一个生成树使得生成树的最大边-最小边的差最小。 题解:按权值排序后遍历L-R的点看是否满足生成树的条件,满...原创 2018-05-19 00:53:51 · 234 阅读 · 0 评论 -
UVA247 - Calling Circles
UVA247 - Calling Circles题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=183题意:n个人互相打电话,则说明他们在一个电话圈,即环内,给定n个人和m次通话,将...原创 2018-05-19 23:26:15 · 246 阅读 · 0 评论 -
UVA10048 - Audiophobia
UVA10048 - Audiophobia题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=989题意:给定N个点M条边,给定q个询问,询问x-y的路径上使得经过的每条边...原创 2018-05-20 00:00:52 · 243 阅读 · 0 评论 -
UVA 1605 - Building for UN
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4480题意:有N个国家,设计一座大楼使每个国家都与其他国家相邻,相邻包括上下左右。题解:N最大50,采取两层,第一层每行相同,第二层每列相同,这样最后就能满足都相邻的条件。...原创 2018-06-11 14:34:51 · 226 阅读 · 0 评论 -
UVAlive 6959 Judging hash
JudgingTime Limit: 20 Sec Memory Limit: 256 MB题目连接http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=114147DescriptionThe NWERC organisers have decided that they want to improve the automati...原创 2018-06-26 02:07:35 · 250 阅读 · 0 评论 -
Colossal Fibonacci Numbers! UVA - 11582
Colossal Fibonacci Numbers! UVA - 11582 The i’th Fibonacci number f(i) is recursively defined in the following way:• f(0) = 0 and f(1) = 1• f(i + 2) = f(i + 1) + f(i) forevery i ≥ 0Your原创 2017-10-12 00:07:26 · 398 阅读 · 0 评论 -
Choose and divide UVA - 10375
Choose and divide UVA - 10375 The binomial coefficient C(m, n) is defined as C(m, n) = m! / (m − n)! n!Given four natural numbers p, q, r, and s, compute the the result of dividing C(p, q) by原创 2017-10-12 17:11:01 · 220 阅读 · 0 评论 -
Disgruntled Judge UVA - 12169
Disgruntled Judge UVA - 12169题意:给定2*T大小的数组,给定奇数项,符合关系x[i] = (a · x[i−1] + b) mod 10001.求各个偶数项。题解:范围10000,可以通过暴力求解过,但是时间复杂度太高,根据公式可以采用拓展欧几里得求解。 可以得到 x2 = (a * x1 + b) % 10001;x3 = (a原创 2017-10-12 23:18:32 · 160 阅读 · 0 评论 -
Minimum Sum LCM UVA - 10791
Minimum Sum LCM UVA - 10791 题意:输入整数N,求至少两个正整数是他们的最小公倍数是N,且整数和最小,输出最小和。题解:利用唯一分解定理求解,坑点有只有一个单因子的时候加一,n=1是输出2。一直wa了很多次的原因是题意的理解错了,对于16这种数我写成了2+2+2+2,但是相同的数最小公倍数并不是N,16应为2^4+1=17。还是太菜了吧。AC代原创 2017-10-13 00:50:09 · 215 阅读 · 0 评论 -
UVa-1585 - Score
题解:循环统计连续的O将对应的分数加上即可。 AC代码:#include#includeusing namespace std;const int maxn = 87;#define _for(i,a,b) for(int i=a;i<=b;i++)char s[maxn];int ans,n;int main(){ scanf("%d",&n);原创 2018-02-04 01:26:31 · 244 阅读 · 0 评论 -
UVa - 1586 - Molar mass
题解:模拟即可,统计每个原子的个数,可能会有两位数的情况,需要进行特殊处理。 AC代码:#include#includeusing namespace std;const int maxn = 87;char s[maxn];int n;bool check(char a){ if(a=='C'||a=='N'||a=='O'||a=='H')return true;原创 2018-02-04 01:45:06 · 210 阅读 · 0 评论 -
UVa - 1225 - Digit Counting
UVa - 1225 - Digit Counting题解:因为N的值很小,直接统计每个数的各位数记录在数组即可。AC代码:#includeusing namespace std;const int maxn = 10007;int a[maxn][10];int t,n;int main(){ scanf("%d",&t); for(int i=1;i<=原创 2018-02-04 16:30:58 · 241 阅读 · 0 评论 -
UVa - 455 - Periodic Strings
455 - Periodic Strings题解:字符串周期满足1-length的长度范围,所以暴力模拟即可,这道题输入每次中间会有空行,需要puts,而输出并不需要特殊处理末尾空行也能A。AC代码:#include#includeusing namespace std;char s[85];int t;bool check(int k,int n){ int原创 2018-02-04 19:07:02 · 193 阅读 · 0 评论 -
UVa - 673 - Parentheses Balance
673 Parentheses Balance 题解:栈的基本使用,左括号入栈,右括号就判断是不是和栈首匹配,注意空串和每次栈的清空。 AC代码:#include#include#include#includeusing namespace std;stack S;int t;char s[260];bool check(char a,char b){原创 2018-02-05 01:26:22 · 197 阅读 · 0 评论