- 博客(67)
- 问答 (3)
- 收藏
- 关注
原创 HDU 4708 Rotation Lock Puzzle
Alice was felling into a cave. She found a strange door with a number square matrix. These numbers can be rotated around the center clockwise or counterclockwise. A fairy came and told her how to solv
2015-08-19 17:46:58 432
转载 ZOJ 3699 Dakar Rally
The Dakar Rally is an annual Dakar Series rally raid type of off-road race, organized by the Amaury Sport Organization. The off-road endurance race consists of a series of routes. In different routes,
2015-08-19 17:09:05 648
原创 ZOJ 3704 I am Nexus Master!
NexusHD.org is a popular PT (Private Tracker) site in Zhejiang University aiming to provide high quality stuff. In order to encourage users to unload more stuff, the administrators make the following
2015-08-19 15:28:18 573
原创 ZOJ 3703 Happy Programming Contest
In Zhejiang University Programming Contest, a team is called "couple team" if it consists of only two students loving each other. In the contest, the team will get a lovely balloon with unique color f
2015-08-19 15:25:15 422
原创 ZOJ 3702 Gibonacci number
In mathematical terms, the normal sequence F(n) of Fibonacci numbers is defined by the recurrence relationF(n)=F(n-1)+F(n-2)with seed values F(0)=1, F(1)=1In this Gibonacci numbers problem, th
2015-08-19 15:18:22 489
原创 HDU 4715 Difference Between Primes
All you know Goldbach conjecture.That is to say, Every even integer greater than 2 can be expressed as the sum of two primes. Today, skywind present a new conjecture: every even integer can be express
2015-08-19 15:15:38 471
原创 HDU 4709 Herding
Little John is herding his father's cattles. As a lazy boy, he cannot tolerate chasing the cattles all the time to avoid unnecessary omission. Luckily, he notice that there were N trees in the meadow
2015-08-19 15:13:55 349
原创 HDU 4707 Pet
One day, Lin Ji wake up in the morning and found that his pethamster escaped. He searched in the room but didn’t find the hamster. He tried to use some cheese to trap the hamster. He put the cheese tr
2015-08-19 15:05:39 462
原创 HDU 4710 Balls Rearrangement
Bob has N balls and A boxes. He numbers the balls from 0 to N-1, and numbers the boxes from 0 to A-1. To find the balls easily, he puts the ball numbered x into the box numbered a if x = a mod A.S
2015-08-19 15:02:41 361
原创 素数的判定
米勒罗宾算法bool test (LL n,LL a,LL d){ if(n==2) return true; if(n==a) return true; if((n&1)==0) return false; while(!(d&1)) d=d>>1; LL t=pow_mod(a,d,n); while((d!=n-1)&&(t!=1
2015-08-17 18:16:17 542
原创 poj 2074 Line of Sight
An architect is very proud of his new home and wants to be sure it can be seen by people passing by his property line along the street. The property contains various trees, shrubs, hedges, and other o
2015-08-17 18:00:59 557
转载 poj 1836 Alignment
In the army, a platoon is composed by n soldiers. During the morning inspection, the soldiers are aligned in a straight line in front of the captain. The captain is not satisfied with the way his sold
2015-08-17 15:17:09 358
原创 poj 1675 Happy Birthday!
There are three berries on a round birthday cake. You are required to divide the cake into three identical parts such that each part contains exactly one berry. To make it easy, it is assumed that the
2015-08-17 14:43:24 750
原创 poj 1673 EXOCENTER OF A TRIANGLE
Given a triangle ABC, the Extriangles of ABC are constructed as follows: On each side of ABC, construct a square (ABDE, BCHJ and ACFG in the figure below). Connect adjacent square corners to form
2015-08-17 14:31:48 444
原创 三角型的性质
三角形顶点坐标:A(x1; y1);B(x2; y2);C(x3; y3);④重心G(x4;y4);x4=(x1+x2+x3)/3;y4=(y1+y2+y3)/3;⑤外心W(x5;y5);根据外心到各顶点的距离相等:AG=BG;AG=CG;即:Sqrt[(x1 - x5)^2 + (y1 - y5)^2] == Sqrt[(x2 - x5)^2 + (y2 - y5)^2],Sqr
2015-08-17 14:14:00 419
原创 HDU 4722 Good Numbers
If we sum up every digit of a number and the result can be exactly divided by 10, we say this number is a good number. You are required to count the number of good numbers in the range from A to B,
2015-08-17 11:17:24 419
原创 HDU 4726 Kia's Calculation
Doctor Ghee is teaching Kia how to calculate the sum of two integers. But Kia is so careless and alway forget to carry a number when the sum of two digits exceeds 9. For example, when she calculates 4
2015-08-17 11:15:44 402
原创 HDU 4720 Naive and Silly Muggles
Three wizards are doing a experiment. To avoid from bothering, a special magic is set around them. The magic forms a circle, which covers those three wizards, in other words, all of them are inside or
2015-08-17 11:13:41 402
原创 poj 1654 Area
You are going to compute the area of a special kind of polygon. One vertex of the polygon is the origin of the orthogonal coordinate system. From this vertex, you may go step by step to the following
2015-08-16 18:10:57 439
转载 叉积与点积
计算几何是算法竞赛的一大块,而叉积是计算机和的基础。首先叉积是计算说向量之间的叉积,那么我们可以这样定义向量,以及向量的运算符重载。[cpp] view plaincopyprint?struct Point { double x,y; Point(double x=0,double y=0):x(x
2015-08-16 18:06:15 747
转载 poj 1319 Pipe Fitters
A company manufactures pipes of uniform diameter. All pipes are stored in rectangular storage containers, but the containers come in several different sizes. Pipes are stored in rows within a containe
2015-08-16 17:27:28 498
转载 poj 1182
食物链Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 53661 Accepted: 15733Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动
2015-08-16 16:54:50 358
原创 背包总结
关于背包问题的讲解,有篇DD牛写的《背包问题九讲》,凭我这水平怎么说也没有这篇文章说的清楚,直接看文章吧。我只把我认为的比较概括的东西写出来。看完背包九讲再来看这个会比较好,我这个只是对背包九讲的总结加上一点点自己的总结和一些经典题目。标注:下文n即为物品件数,c[i]表示第i件物品的耗费(体积),V为背包容量,a[i]表示第i件物品的价值 dp[]数组存放的即为最优解。一、01背包
2015-08-16 14:51:42 463
原创 CSU 1120 病毒
你有一个日志文件,里面记录着各种系统事件的详细信息。自然的,事件的时间戳按照严格递增顺序排列(不会有两个事件在完全相同的时刻发生)。遗憾的是,你的系统被病毒感染了,日志文件中混入了病毒生成的随机伪事件(但真实事件的相对顺序保持不变)。备份的日志文件也被感染了,但由于病毒采用的随机感染方法,主日志文件和备份日志文件在感染后可能会变得不一样。给出被感染的主日志和备份日志,求真实事件序列的最长可
2015-08-10 20:56:29 423
原创 CSU 1115 最短的名字
在一个奇怪的村子中,很多人的名字都很长,比如aaaaa, bbb and abababab。名字这么长,叫全名显然起来很不方便。所以村民之间一般只叫名字的前缀。比如叫'aaaaa'的时候可以只叫'aaa',因为没有第二个人名字的前三个字母是'aaa'。不过你不能叫'a',因为有两个人的名字都以'a'开头。村里的人都很聪明,他们总是用最短的称呼叫人。输入保证村里不会有一个人的名字是另外一个人名字
2015-08-10 20:55:33 413
原创 CSU 1113 Updating a Dictionary
In this problem, a dictionary is collection of key-value pairs, where keys are lower-case letters, and values are non-negative integers. Given an old dictionary and a new dictionary, find out what wer
2015-08-10 20:54:18 579
原创 ZOJ 3212 K-Nice
This is a super simple problem. The description is simple, the solution is simple. If you believe so, just read it on. Or if you don't, just pretend that you can't see this one.We say an element is
2015-08-10 20:41:37 358
原创 ZOJ 3211 Dream City
JAVAMAN is visiting Dream City and he sees a yard of gold coin trees. There are n trees in the yard. Let's call them tree 1, tree 2 ...and tree n. At the first day, each tree i has ai coins on it (i=1
2015-08-10 20:40:11 398
原创 ZOJ 3203 Light Bulb
Compared to wildleopard's wealthiness, his brother mildleopard is rather poor. His house is narrow and he has only one light bulb in his house. Every night, he is wandering in his incommodious house,
2015-08-10 20:38:21 396
原创 UVA 232 Crossword Answers
http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=32396uva232题目弄不下来#include #include struct p{ int x,y;} ma[15][15];int main(){ int n,m,t=1,i,j,tt=0; int ansa[10
2015-08-10 20:33:21 379
原创 UVA 1587 Box
Ivan works at a factory that produces heavy machinery. He has a simple job -- he knocks up wooden boxes of different sizes to pack machinery for delivery to the customers. Each box is a rectangular
2015-08-10 20:27:45 526
原创 UVA 1225 Digit Counting
Trung is bored with his mathematics homeworks. He takes a piece of chalk and starts writing a sequence of consecutive integers starting with 1 to N(1 N . After that, he counts the number of times e
2015-08-10 20:20:30 341
原创 UVA 227 Puzzle
A children's puzzle that was popular 30 years ago consisted of a 55 frame which contained 24 smallsquares of equal size. A unique letter of the alphabet was printed on each small square. Since there
2015-08-10 20:03:10 421
原创 CSU 1337 搞笑版费马大定理
费马大定理:当n>2时,不定方程an+bn=cn没有正整数解。比如a3+b3=c3没有正整数解。为了活跃气氛,我们不妨来个搞笑版:把方程改成a3+b3=c3,这样就有解了,比如a=4, b=9, c=79时43+93=793。输入两个整数x, y, 求满足xInput输入最多包含10组数据。每组数据包含两个整数x, y(18)。Output对于每组数
2015-08-10 19:55:45 470
原创 CSU 1334 好老师
我想当一个好老师,所以我决定记住所有学生的名字。可是不久以后我就放弃了,因为学生太多了,根本记不住。但是我不能让我的学生发现这一点,否则会很没面子。所以每次要叫学生的名字时,我会引用离他最近的,我认得的学生。比如有10个学生:A ? ? D ? ? ? H ? ?想叫每个学生时,具体的叫法是:位置叫法1A2
2015-08-10 19:54:08 438
原创 CSU 1328 近似回文词
输入一行文本,输出最长近似回文词连续子串。所谓近似回文词是指满足以下条件的字符串:1. S以字母开头,字母结尾2. a(S)和b(S)最多有2k个位置不同,其中a(S)是S删除所有非字母字符并且把所有字母转化成小写之后得到的串,b(S)是a(S)的逆序串。比如当k=1时,Race cat是一个近似回文词,因为a(S)=racecat和b(S)=tacecar只有2个位置不同。
2015-08-10 19:51:05 683
原创 CSU 1513 Kick the ball!
"A penalty shoot-out (officially kicks from the penalty mark) is a method of determining the winner of an association football (soccer) match that is drawn after the regulation playing time and any ap
2015-08-10 19:47:34 682
原创 CSU 1511 残缺的棋盘
Input输入包含不超过10000 组数据。每组数据包含6个整数r1, c1, r2, c2, r3, c3 (1Output对于每组数据,输出测试点编号和最少步数。Sample Input1 1 8 7 5 61 1 3 3 2 2Sample OutputCase 1: 7C
2015-08-10 19:46:04 705
原创 ZOJ 3204 Connect them
You have n computers numbered from 1 to n and you want to connect them to make a small local area network (LAN). All connections are two-way (that is connecting computers i and j is the same as connec
2015-08-09 22:51:23 446
转载 搜索 剪枝
搜索算法的通用优化方法[DFS][搜索剪枝]在很多情况下,我们已经找到了一组比较好的解。但是计算机仍然会义无返顾地去搜索比它更“劣”的其他解,搜索到后也只能回溯。为了避免出现这种情况,我们需要灵活地去定制回溯搜索的边界。*例题 计算机网络连接要将n(n求:一种连接方式,使需要电缆的长度最短。分析这个题目用回溯搜索来解决。但是,由于回溯搜索的搜索量比较大,
2015-08-09 22:12:57 448
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人