摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3534题意:给出一颗树(n个顶点,n-1条边)求最长的路径,以及最长路径的条数。路径无非就是连接两个点直接的路。因为是一颗树,所以连接两个点肯定是唯一的路径。其实就是求两点间距离的最大值,以及这个最大值有多少个。很裸的树形DP;首先统计出结点到叶子结点的最长距离和次长距离。然后找寻经过这个点的,在这个为根结点的子树中的最长路径个数目。代码:#include <string.h>#include <iostream>#include <algorithm>#incl
阅读全文
摘要:今天的比赛。。。。。速度还是慢了。。。无缘无故错误提交好多次。。哭了。。。。比较简单:A题:HDU 4557非诚勿扰链接:http://acm.hdu.edu.cn/showproblem.php?pid=4557暴力胡搞,水题://============================================================================// Name : A.cpp// Author : // Version :// Copyright : Your copyright notice// Description...
阅读全文
摘要:Problem B: Fire!Joe works in a maze. Unfortunately, portions of the maze have caught on fire, and the owner of the maze neglected to create a fire escape plan. Help Joe escape the maze.Given Joe's location in the maze and which squares of the maze are on fire, you must determine whether Joe can
阅读全文
摘要:M斐波那契数列Time Limit: 3000/1000 MS (Java/Others)Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 353Accepted Submission(s): 93Problem DescriptionM斐波那契数列F[n]是一种整数数列,它的定义如下:F[0] = aF[1] = bF[n] = F[n-1] * F[n-2] ( n > 1 )现在给出a, b, n,你能求出F[n]的值吗?Input输入包含多组测试数据;每组数据占一行,包含3个整数a, b, n( 0 <
阅读全文
摘要:卡片游戏Time Limit: 3000/1000 MS (Java/Others)Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 376Accepted Submission(s): 115Problem Description 小明最近宅在家里无聊,于是他发明了一种有趣的游戏,游戏道具是N张叠在一起的卡片,每张卡片上都有一个数字,数字的范围是0~9,游戏规则如下: 首先取最上方的卡片放到桌子上,然后每次取最上方的卡片,放到桌子上已有卡片序列的最右边或者最左边。当N张卡片全部都放到桌子上后,桌子上的N张卡片构成了..
阅读全文
摘要:Prime DistanceTime Limit:1000MSMemory Limit:65536KTotal Submissions:9322Accepted:2531DescriptionThe branch of mathematics called number theory is about properties of numbers. One of the areas that has captured the interest of number theoreticians for thousands of years is the question of primality.
阅读全文
摘要:生日猜猜猜Time Limit: 3000/1000 MS (Java/Others)Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 460Accepted Submission(s): 176Problem Description小明对生日十分看重,因为他可以得到祝福,可以和朋友亲人一起分享快乐,可以为自己的人生做一次总结,并且...能够收到好多礼物!不过小明是个神秘的人,不会轻易告诉你他的生日,现在他想到一个办法,让你去猜他的生日是哪一天。小明会告诉你如下三个信息:1. 出生月份和出生日子的最大公约数;2. 出生月
阅读全文
摘要:怪盗基德的挑战书Time Limit: 3000/1000 MS (Java/Others)Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 345Accepted Submission(s): 163Problem Description “在树最美丽的那天,当时间老人再次把大钟平均分开时,我会降临在灯火之城的金字塔前,带走那最珍贵的笑容。”这是怪盗基德盗取巴黎卢浮宫的《蒙娜丽莎的微笑》这幅画时,挑战书上的内容。 但这次,怪盗基德的挑战书上出现了一串串小写字母“aaab sdfeeddd...”。柯南以小学生的眼睛..
阅读全文
摘要:约会安排Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 147Accepted Submission(s): 47Problem Description 寒假来了,又到了小明和女神们约会的季节。 小明虽为屌丝级码农,但非常活跃,女神们常常在小明网上的大段发言后热情回复“呵呵”,所以,小明的最爱就是和女神们约会。与此同时,也有很多基友找他开黑,由于数量实在过于巨大,怎么安排时间便成了小明的一大心事。 我们已知小明一共有T的空闲时间,期间会有...
阅读全文
摘要:打算转下来好好做计算几何了。原文地址:http://blog.sina.com.cn/s/blog_49c5866c0100f3om.html其实也谈不上推荐,只是自己做过的题目而已,甚至有的题目尚未AC,让在挣扎中。之所以推荐计算几何题,是因为,本人感觉ACM各种算法中计算几何算是比较实际的算法,在很多领域有着重要的用途计算几何题的特点与做题要领:1.大部分不会很难,少部分题目思路很巧妙2.做计算几何题目,模板很重要,模板必须高度可靠。3.要注意代码的组织,因为计算几何的题目很容易上两百行代码,里面大部分是模板。如果代码一片混乱,那么会严重影响做题正确率。4.注意精度控制。5.能用整数的地方
阅读全文
摘要:CD操作Time Limit: 10000/5000 MS (Java/Others)Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 78Accepted Submission(s): 14Problem Description 在Windows下我们可以通过cmd运行DOS的部分功能,其中CD是一条很有意思的命令,通过CD操作,我们可以改变当前目录。 这里我们简化一下问题,假设只有一个根目录,CD操作也只有两种方式: 1. CD 当前目录名\...\目标目录名 (中间可以包含若干目录,保证目标目录通过绝对路...
阅读全文
摘要:比赛难度Time Limit: 3000/1000 MS (Java/Others)Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 46Accepted Submission(s): 6Problem Description 最近,小明出了一些ACM编程题,决定在HDOJ举行一场公开赛。 假设题目的数量一共是n道,这些题目的难度被评级为一个不超过1000的非负整数,并且一场比赛至少需要一个题,而这场比赛的难度,就是所有题目的难度之和,同时,我们认为一场比赛与本场题目的顺序无关,而且题目也不会重复。 显而易见,很容...
阅读全文
摘要:魔法串Time Limit: 3000/1000 MS (Java/Others)Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 70Accepted Submission(s): 37Problem Description 小明和他的好朋友小西在玩一个新的游戏,由小西给出一个由小写字母构成的字符串,小明给出另一个比小西更长的字符串,也由小写字母组成,如果能通过魔法转换使小明的串和小西的变成同一个,那么他们两个人都会很开心。这里魔法指的是小明的串可以任意删掉某个字符,或者把某些字符对照字符变化表变化。如: 小西...
阅读全文
摘要:K - Yet another end of the world时间限制:5000 Ms内存限制:65535 Kb问题描述In the year 3013, it has been 1000 years since the previous predicted rapture. However, the Maya will not play a joke any more and the Rapture finally comes in. Fortunately people have already found out habitable planets, and made enough a
阅读全文
摘要:C - Count The Carries时间限制:3000 Ms内存限制:65535 Kb问题描述One day, Implus gets interested in binary addition and binary carry. He will transfer all decimal digits to binary digits to make the addition. Not as clever as Gauss, to make the addition from a to b, he will add them one by one from a to b in order
阅读全文
摘要:A - Play the Dice时间限制:2000 MS内存限制:65535 MB问题描述There is a dice withN sides, which are numbered from 1,2,...,n and have the equal possibility to show up when one rolls a dice. Each side has an integer Aion it. Now here is a game that you can roll this dice once, if the i-th side is up, you will getAiy
阅读全文
摘要:南京邀请赛算是我第一次参加的邀请赛吧(以前只参加了区域赛)。这次比赛根据教练的安排是和两个大二的小朋友组队,感觉还是蛮好的,可以带着学弟学妹出去训练,但是压力也确实蛮大的,所以比赛前一个月花了很多的时间去准备,找比赛的感觉。这次根据铎铎妹的建议,取了队名AC_lions,感觉还是很不错的,也是给铎铎做广告吧~~ 因为这次去的南京比较近,而且我们学校去三个队,所以行程还是比较紧的,11号早上7:00坐高铁去南京,12号晚上8点回来。11号早早就起来去火车站了,然后坐高铁去了南京,之后坐地铁到了南京理工大学,找到了志愿者,然后去住的宾馆,竟然还没有房间,叫我们12点以后回来。然后就先去南京理工..
阅读全文
摘要:LawrenceTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1523Accepted Submission(s): 671Problem DescriptionT. E. Lawrence was a controversial figure during World War I. He was a British officer who served in the Arabian theater and led a group of Ar
阅读全文
摘要:Cut the SequenceTime Limit:2000MSMemory Limit:131072KTotal Submissions:7972Accepted:2287DescriptionGiven an integer sequence {an} of lengthN, you are to cut the sequence into several parts every one of which is a consecutive subsequence of the original sequence. Every part must satisfy that the sum
阅读全文
摘要:SubsequenceTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3266Accepted Submission(s): 1063Problem DescriptionThere is a sequence of integers. Your task is to find the longest subsequence that satisfies the following condition: the difference betwe
阅读全文
摘要:Nim or not Nim?Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 540Accepted Submission(s): 246Problem DescriptionNim is a two-player mathematic game of strategy in which players take turns removing objects from distinct heaps. On each turn, a player
阅读全文
摘要:Euclid's GameTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1116Accepted Submission(s): 516Problem DescriptionTwo players, Stan and Ollie, play, starting with two natural numbers. Stan, the first player, subtracts any positive multiple of the
阅读全文
摘要:Marriage Match IVTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1514Accepted Submission(s): 427Problem DescriptionDo not sincere non-interference。Like that show, now starvae also take part in a show, but it take place between city A and B. Starvae
阅读全文
摘要:Marriage Match IIITime Limit: 10000/4000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 771Accepted Submission(s): 236Problem DescriptionPresumably, you all have known the question of stable marriage match. A girl will choose a boy; it is similar as the ever game of pl
阅读全文
摘要:Marriage Match IITime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1085Accepted Submission(s): 388Problem DescriptionPresumably, you all have known the question of stable marriage match. A girl will choose a boy; it is similar as the game of playing
阅读全文
摘要:EscapeTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2523Accepted Submission(s): 691Problem Description2012 If this is the end of the world how to do? I do not know how. But now scientists have found that some stars, who can live, but some people
阅读全文
摘要:kebabTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 489Accepted Submission(s): 211Problem DescriptionAlmost everyone likes kebabs nowadays (Here a kebab means pieces of meat grilled on a long thin stick). Have you, however, considered about the ha
阅读全文
摘要:Kakuro ExtensionTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 590Accepted Submission(s): 204Special JudgeProblem DescriptionIf you solved problem likethis, forget it.Because you need to use a completely different algorithm to solve the following
阅读全文
摘要:Leapin' Lizards题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2732题目意思看起来比较难懂。题目是说一个n*m的迷宫中,有每个格子有柱子。柱子高度为0~3,高度为0的柱子是不能站的(高度为0就是没有柱子)在一些有柱子的格子上有一些蜥蜴,一次最多跳距离d,相邻格子的距离是1,只要跳出迷宫就是安全的。这个距离是曼哈顿距离(好像是的)。蜥蜴一次最多跳距离d,但是起跳的地方的柱子高度会减一,一个柱子同一时间只能有一个蜥蜴要求最少几个不能逃出迷宫。具体意思看题目吧,很多描述不清呢~~还是英语好啊做法就是最大流。要拆点,两个点的容量就
阅读全文
摘要:吉哥系列故事——恨7不成妻Time Limit: 1000/500 MS (Java/Others)Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 746Accepted Submission(s): 227Problem Description 单身! 依然单身! 吉哥依然单身! DS级码农吉哥依然单身! 所以,他生平最恨情人节,不管是214还是77,他都讨厌! 吉哥观察了214和77这两个数,发现: 2+1+4=7 7+7=7*2 77=7*11 最终,他发现原来这一切归根到底都是因为和7有...
阅读全文
摘要:题目链接:http://www.spoj.com/problems/BALNUM/这题要求出现的数字,偶数出现奇数次,奇数出现偶数次。用三进制表示0~9的状态//============================================================================// Name : SPOJ.cpp// Author : // Version :// Copyright : Your copyright notice// Description : Hello World in C++, Ansi-style...
阅读全文
摘要:Balanced NumberTime Limit:5 Seconds Memory Limit:65536 KBA balanced number is a non-negative integer that can be balanced if a pivot is placed at some digit. More specifically, imagine each digit as a box with weight indicated by the digit. When a pivot is placed at some digit of the number, the dis
阅读全文
摘要:B-numberTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1231Accepted Submission(s): 651Problem DescriptionA wqb-number, or B-number for short, is a non-negative integer whose decimal form contains the sub- string "13" and can be divided b
阅读全文
摘要:D. Beautiful numberstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVolodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number isbeautifulif and only if it is divisible by each of its nonzero digits. We
阅读全文
摘要:XHXJ's LISTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 376Accepted Submission(s): 163Problem Description#define xhxj (Xin Hang senior sister(学姐))If you do not know xhxj, then carefully reading the entire description is very important.As the
阅读全文