UVa
文章平均质量分 78
ACMega
精通C/C Java 要饭
展开
-
Uva1328 - Period
KMP#include #define INF (int)(1e9)#define maxn 1000010#define sigma_size 100using namespace std;char str[maxn];int f[maxn];void GetNext(char *p) { int m = strlen(p); f[0] = f[1] = 0;原创 2014-05-15 01:43:16 · 214 阅读 · 0 评论 -
UVA11044 - Searching for Nessy
写的忘了一个问题,整除和余数。题目: Searching for Nessy Searching for Nessy The Loch Ness Monsteris a mysterious and unidentified animal said to inhabit Loch Ness, a large deep freshwat原创 2013-03-02 21:44:31 · 273 阅读 · 0 评论 -
UVA10790 - How Many Points of Intersection?
刚开始有点被书“误导”了,上来就想用一下公式,结果连简单的排列组合都忘了。数据结果很大要用long long题目: How Many Points of Intersection? We have two rows. There are a dots on the top row andb dots on the bottom row.原创 2013-03-02 20:19:26 · 263 阅读 · 0 评论 -
UVA846 - Steps
找规律可以发现一个数列 (0),1,2,4,6,9,12,16,20....分别是1步,2步,3步,4步....的最大距离。然后把x-y锁定到一个区间就行了。注意距离为0的时候走0步。题目: Steps Steps One steps through integer points of the straight line. The lengt原创 2013-03-02 18:34:11 · 243 阅读 · 0 评论 -
UVA253 - Cube painting
WA的原因竟然因为....竟然因为...把TRUE拼成TURE了...英死早,囧...题目:Cube painting Cube painting We have a machine for painting cubes. It is supplied with three different colors: blue, red and gre原创 2013-03-01 22:50:32 · 278 阅读 · 0 评论 -
UVA10499 - The Land of Justice
题目不太好懂,看了别人的翻译。大概意思就是,球形表面积增加量比上原表面积,其实就是n/4*100%题目: Problem HThe Land of JusticeInput: standard inputOutput: standard outputTime Limit: 4 secondsIn the Land of Justice theselling原创 2013-03-02 19:19:53 · 213 阅读 · 0 评论 -
UVA591 - Box of Bricks
没难度~题目: Box of Bricks Little Bob likes playing with his box of bricks. He puts the bricks one upon another and builds stacks of different height. ``Look, I've built a wall!'原创 2013-03-02 11:12:29 · 243 阅读 · 0 评论 -
UVA10025 - The ? 1 ? 2 ? ... ? n = k problem
算法需要自己猜,参考了题解。题目: The ? 1 ? 2 ? ... ? n = k problem TheproblemGiven the following formula, one can set operators '+' or '-' instead of each '?', in order to obtain a giv原创 2013-03-02 10:50:23 · 185 阅读 · 0 评论 -
UVA621 - Secret Research
没啥说的,题目没看懂,但是数据很一般,很好AC。题目: Secret Research Secret Research At a certain laboratory results of secret research are thoroughly encrypted. A result of a single experiment is原创 2013-03-02 10:15:47 · 208 阅读 · 0 评论 -
UVA10161 - Ant on a Chessboard
开学了,从现在开始吧~题目: Problem A.Ant on a Chessboard Background One day, an ant calledAlice came to an M*M chessboard. She wanted to go around all the grids. So shebegan原创 2013-03-01 13:57:41 · 234 阅读 · 0 评论 -
UVA573 - The Snail
注意:1. 判定成功的时候不要减去滑下的距离2.上升距离为负时要保持为0题目: The Snail A snail is at the bottom of a 6-foot well and wants to climb to the top. The snail can climb 3 feet while the sun is up原创 2013-03-02 18:08:49 · 188 阅读 · 0 评论 -
UVA107 - The Cat in the Hat
精度控制+查找题目:The Cat in the Hat The Cat in the Hat Background(An homage to Theodore Seuss Geisel)The Cat in the Hat is a nasty creature,But the striped hat he is weari原创 2013-03-02 15:15:48 · 229 阅读 · 0 评论 -
UVA10177 - (2/3/4)-D Sqr/Rects/Cubes/Boxes?
数据用long long题目: Problem J - Regionals 2001 Warmup Contest<!--p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Rom原创 2013-03-03 16:18:57 · 242 阅读 · 0 评论 -
UVA10916 - Factstone Benchmark
第一次TLE了,想到了取对数的方法,但是纠结 2^x-1 后面的 -1 一直保留所以计算超时了。后来实验了一两次,发现 x = 4 的时候 3! = 6 题目: Problem B: Factstone BenchmarkAmtel has announced that it will release a 128-bit computer chip by 2010, a 256-b原创 2013-03-03 23:20:13 · 218 阅读 · 0 评论 -
UVA10014 - Simple calculations
公式:a1 = n * a0 / (n + 1) + an+1 / (n + 1) + ∑∑ci题目: Simple calculations Simple calculations The ProblemThere is a sequence ofn+2 elements a0, a1,…, an+1(n i 10原创 2013-03-04 11:17:53 · 288 阅读 · 0 评论 -
UVa11732 - strcmp() Anyone?
Trie#include #define sigma_size 100#define maxnode 4000010typedef long long ll;using namespace std;ll ans;struct Trie { struct Node { int val;//记录结点字母 int cnt;//记录节点字母出现次数原创 2014-05-15 00:22:45 · 204 阅读 · 0 评论 -
Uva1401 - Remember the Word
#include #define maxn 100010#define INF (int)(1e9)#define MOD 20071027#define maxnode 500010#define sigma_size 30typedef long long ll;using namespace std;int dp[maxnode];char str[max原创 2014-05-06 01:02:09 · 320 阅读 · 0 评论 -
UVA11300 - Spreading the Wealth
#include #include #include #include #include #include #include using namespace std;long long a[1000010];long long c[1000010];int main() { int n; while (scanf("%d", &n) != EOF) { long lon原创 2014-01-20 17:23:51 · 286 阅读 · 0 评论 -
10881 - Piotr's Ants
开始和结束,蚂蚁的顺序不变。#include #include #include #include #include #include #include using namespace std;struct P { int id, p, v;}before[10010], after[10010];bool cmp (P a, P b) { return a.p < b原创 2014-01-20 20:12:21 · 283 阅读 · 0 评论 -
UVa11384 - Help is needed for Dexter
很像Codeforces div.2 B or C 难度的题#include #include #include #include #include #include #include #include #include using namespace std;int work(int n) { if (n == 1) return 1; else return wor原创 2014-01-28 14:36:41 · 266 阅读 · 0 评论 -
UVA11729 - Commando War
#include #include #include #include #include #include #include using namespace std;struct P { int a, b;}job[1010];bool cmp (P a, P b) { return a.b > b.b;}int main() { int N, now = 0; w原创 2014-01-20 11:17:35 · 279 阅读 · 0 评论 -
UVA11292 - Dragon of Loowater
#include #include #include #include #include #include #include using namespace std;int a[20010], b[20010];int main() { int n, m; while (scanf("%d%d", &n, &m) != EOF) { if (n == 0 && m ==原创 2014-01-20 10:56:50 · 223 阅读 · 0 评论 -
UVa11520 - Fill the Square
简单的爆搜#include #include #include #include #include #include #include #include #include #include #define MAXN 15using std::cin;using std::cout;using std::endl;using std::map;using std::原创 2014-01-28 23:25:25 · 261 阅读 · 0 评论 -
UVa10795 - A Different Task
因为有状态转移,可以说是一道DP,递归代码#include #include #include #include #include #include #include #include #include #define MAXN 100using std::cin;using std::cout;using std::endl;int start[MAXN], end原创 2014-01-28 18:36:38 · 244 阅读 · 0 评论 -
UVA11235 - Frequent values
RMQ#include #include #include #include #define MAXN 100010#define INF (~0U >> 2)using std::max;int d[100010][20], a[100010], num[100010], left[100010], right[100010], count[100010], value[1原创 2013-10-25 15:10:57 · 298 阅读 · 0 评论 -
UVA11991 - Easy Problem from Rujia Liu?
熟悉一下STL用法:map:m.count(a) 返回第一维中a的个数;m[a].size() 返回m[a]中元素的个数;a.clear() 清空a;/****************************************************/#include #include #include #include #include #inclu原创 2013-08-14 22:08:13 · 234 阅读 · 0 评论 -
UVA10785 The Mad Numerologist
虽然是sorting的压轴,但是比起前面真心水题。这个专题结合前面string的很多,排序相对简单了,qsort基本解决。题目: The Mad Numerologist Numerology is a science that is used by many people to find out a mans personality, sole原创 2013-02-20 17:35:08 · 164 阅读 · 0 评论 -
UVA10106 Product
高精度乘法题目:Product Product The ProblemThe problem is to multiply two integers X, Y. (0250)The InputThe input will consist of a set of pairs of lines. Each line in pair原创 2013-02-20 17:34:29 · 143 阅读 · 0 评论 -
UVA299 Train Swapping
简单的冒泡排序,这题是练英语阅读的。题目:Train Swapping Train Swapping At an old railway station, you may still encounter one of the last remaining ``train swappers''. A train swapper is an emp原创 2013-02-20 17:34:51 · 151 阅读 · 0 评论 -
UVA10474 Where is the Marble?
我认为是uva上最简单的题了。题目:Where is the Marble? Where is the Marble? Raju and Meena love to play with Marbles. They have got a lot of marbles with numbers written on them. At the be原创 2013-02-20 17:34:46 · 209 阅读 · 0 评论 -
UVA340 Master-Mind Hints
快过年了,当然还是要刷题。题目好长,看了看翻译,英语水平拙计啊。把Strong的hint抛去,然后记录其他数字出现的次数,累加相同数字中最小的,不错的算法!题目:Master-Mind Hints Master-Mind Hints MasterMind is a game for two players. One of them, D原创 2013-02-20 17:34:38 · 147 阅读 · 0 评论 -
UVA424 Integer Inquiry
一道高精度加法运算,原来做过两道相似的。不过看了书之后还是尝试用了一下模板,套用标准C还是出现了一点问题。加法函数的时候竟然会把全局定义的结构变量值清空。题目:Integer Inquiry Integer Inquiry One of the first users of BIT's new supercomputer was Chip原创 2013-02-20 17:34:26 · 157 阅读 · 0 评论 -
UVA10878 Decode the tape
哎,哎,哎。本来以为很简单的题,结果还是WA了一次,RE了两次。题目看似复杂,其实本身很好理解。把' '看成0,‘o’看成1。就是二进制的ascii码。但是,千万不要用数组储存输入,会超时。解决方法就是用getchar()一个一个读取,读满8个就putchar()出来。还有,不能仅用换行符当作输出的判断条件。不然读到第一行和最后一行的时候会输出空字符'\0'。尤其在terminal下,原创 2013-02-20 17:34:14 · 216 阅读 · 0 评论 -
UVA409 Excuses, Excuses!
需要把excuses数组转换为小写,但是输出的时候要保持原样。因为这个问题WA了很多次。题目: Excuses, Excuses! Judge Ito is having a problem with people subpoenaed for jury duty giving rather lame excuses in order to原创 2013-02-20 17:34:11 · 159 阅读 · 0 评论 -
UVA120 Stacks of Flapjacks
算法想了一阵,不过因为数据量本身不大,还是很容易A的。1.整体qsort一遍,放另外一个数组里面,如果数字所在位置和排序后相同,则称为已定位2.从未定位stack中找最大值3.把最大值翻到top-stack,如果在top-stack就跳过4.从未定位的位置开始整体翻过来5.最大值已定位,重复2题目: Stacks of Flapjacks St原创 2013-02-20 17:34:53 · 158 阅读 · 0 评论 -
UVA10420 List of Conquests
今天除夕哈~祝acmer新年多多AC~~这次又因为英文没看懂题目,以为名字有多个。这个题目没有考虑重名的情况,应该是个小bug吧。虽然是简单的题,不过也学习了qsort套用结构体排序,可以参考七种qsort排序方法。题目: v\:* {behavior:url(#default#VML);}o\:* {behavior:url(#default#VML);}w\:* {原创 2013-02-20 17:34:43 · 201 阅读 · 0 评论 -
UVA465 Overflow
高精度运算,涉及加法、乘法和比大小。一不留神就写了百行,WA的原因是output没有把输入再打印一遍。不过改的时候也考虑了一下前导零,用了clean()函数。可能不考虑也能A,题里面又没说嘛。题目:Overflow Overflow Write a program that reads an expression consisting原创 2013-02-20 17:34:31 · 184 阅读 · 0 评论 -
UVA401 Palindromes
题目:Palindromes A regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string "ABCDEDCBA" is a palindrome because it is the sa原创 2013-02-20 17:34:04 · 161 阅读 · 0 评论 -
UVA10970 - Big Chocolate
很简单的题~题目:Problem G<!--@font-face {font-family:Nazanin}p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman"原创 2013-03-04 09:34:58 · 278 阅读 · 0 评论 -
UVA156 Ananagrams
下次直接用qsort把单词排序就行了,这次的代码有点麻烦,不过自我感觉效率应该比较高。题目:Ananagrams Ananagrams Most crossword puzzle fans are used to anagrams--groups of words with the same letters in different ord原创 2013-02-20 17:34:56 · 168 阅读 · 0 评论