HDU
Kelisita
别再抱怨东西太难,只是自己不会,仅此而已
展开
-
HDU 4704 [费马小定理+快速幂] ---狗眼不识多校
Description Input 2 Output 2 Hint 1. For N = 2, S(1) = S(2) = 1. 2. The input file consists of multiple test cases.原创 2016-08-10 15:47:42 · 403 阅读 · 0 评论 -
HDU 1710 Binary Tree Traversals
Problem Description A binary tree is a finite set of vertices that is either empty or consists of a root r and two disjoint binary trees called the left and right subtrees. There are three most imp原创 2016-07-11 15:16:09 · 216 阅读 · 0 评论 -
HDU 2897(巴什博奕)
Description 当日遇到月,于是有了明。当我遇到了你,便成了侣。 那天,日月相会,我见到了你。而且,大地失去了光辉,你我是否成侣?这注定是个凄美的故事。(以上是废话) 小t和所有世俗的人们一样,期待那百年难遇的日食。驻足街头看天,看日月渐渐走近,小t的脖子那个酸呀(他坚持这个姿势已经有半个多小时啦)。他低下仰起的头,环顾四周。忽然发现身边竟站着位漂亮的mm。天渐渐暗下,这mm原创 2016-04-22 21:07:34 · 257 阅读 · 0 评论 -
HDU 1205 吃糖果 [组合数]
Problem Description HOHO,终于从Speakless手上赢走了所有的糖果,是Gardon吃糖果时有个特殊的癖好,就是不喜欢将一样的糖果放在一起吃,喜欢先吃一种,下一次吃另一种,这样;可是Gardon不知道是否存在一种吃糖果的顺序使得他能把所有糖果都吃完?请你写个程序帮忙计算一下。 Input 第一行有一个整数T,接下来T组数据,每组数据占2行,第一行是一个整数N(0<N原创 2016-05-06 17:36:03 · 482 阅读 · 0 评论 -
HDU 1194 Beat the Spread! 【水题+细心】
Problem Description Superbowl Sunday is nearly here. In order to pass the time waiting for the half-time commercials and wardrobe malfunctions, the local hackers have organized a betting pool on th原创 2016-05-05 11:29:08 · 330 阅读 · 0 评论 -
HDU 1097 A hard puzzle (规律&&快速幂)
Problem Description lcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius: gave a and b,how to know the a^b.everybody objects to this BT problem,so lcy makes the problem easier than begin.原创 2016-05-03 15:21:46 · 282 阅读 · 0 评论 -
HDU 1878 欧拉回路 【基础并查集】
欧拉回路 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 12048 Accepted Submission(s): 4438 Problem Description 欧拉回路是指不令笔离开纸面,可画过图中每原创 2016-04-15 19:02:19 · 238 阅读 · 0 评论 -
HDU 2120 Ice_cream's world I
Description ice_cream's world is a rich country, it has many fertile lands. Today, the queen of ice_cream wants award land to diligent ACMers. So there are some watchtowers are set up, and wall bet原创 2016-03-28 19:13:15 · 220 阅读 · 0 评论 -
HDU 1272
Description 上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条路径可以相通(除非走了回头路)。小希现在把她原创 2016-03-26 21:54:25 · 260 阅读 · 0 评论 -
HDU 1856 More is better
Description Mr Wang wants some boys to help him with a project. Because the project is rather complex, the more boys come, the better it will be. Of course there are certain requirements. Mr Wa原创 2016-03-25 19:44:40 · 279 阅读 · 0 评论 -
HDU 1548 A strange lift
A strange lift Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 18518 Accepted Submission(s): 6864 Problem Description There is a原创 2016-03-24 21:18:15 · 344 阅读 · 0 评论 -
HDU 2544 最短路
最短路 Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 48703 Accepted Submission(s): 21427 Problem Description 在每年的校赛里,所有进入决赛的同学都会获得一原创 2016-03-20 17:53:51 · 258 阅读 · 0 评论 -
HDU 2066 一个人的旅行
题目意思就是中文意思; 有几点注意的: 1.输入的边是从1开始的,但是没有告诉具体点数,所以要统计; 2.第n+1-行给的是和小草家里相连的,所以意思就是从家--->车站--->想去的地方; 因此,,思路就是把家到车站权值变为0,然后从车站开始搜最短路,这两个处理可以用一次dijkstra Problem Description 虽然草儿是个路痴(就是在杭电待了一年多,居然还原创 2016-03-22 14:01:59 · 378 阅读 · 0 评论 -
HDU 3466 【DP入门之01背包】
我觉得我是意识模糊了,同样的错误犯了两次; 错误如下: (1)状态转移方程 总是把 dp[j-a[i].p]+a[i].v 的 j 写为 m ,而且 i 写成 j 这个题: 给出物品数量N和手中资金M 然后每样物品给出价格P,需要购买时手中至少需要多少资金Q,还有物品本身的价值V 要求求出可以需求的最大资金 唯一的坑点就是P-Q排序了 结构体搞就行了;因为题中说了,不到原创 2016-01-26 00:19:41 · 291 阅读 · 0 评论 -
HDU 2844 coin 【多重背包】--暂时还不会全部,待补
Description Whuacmers use coins.They have coins of value A1,A2,A3...An Silverland dollar. One day Hibix opened purse and found there were some coins. He decided to buy a very nice watch in a nearby原创 2016-02-21 23:09:15 · 265 阅读 · 0 评论 -
HDU 1285 确定比赛名次 【入门拓扑排序】
Description 有N个比赛队(1 Input 输入有若干组,每组中的第一行为二个数N(1 Output 给出一个符合要求的排名。输出时队伍号之间有空格,最后一名后面没有空格。 其他说明:符合条件的排名可能不是唯一的,此时要求输出时编号小的队伍在前;输入数据保证是正确的,即输入数据确保一定能有一个符合要求的排名原创 2016-04-01 13:44:32 · 278 阅读 · 0 评论 -
HDU 1102 Constructing Roads [已知路径修好求最小生成树]
Problem Description There are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each other. We say two village A and B are conn原创 2016-07-24 01:39:48 · 276 阅读 · 0 评论 -
HDU 2063 过山车 [匈牙利算法之最大匹配问题]
Description RPG girls今天和大家一起去游乐场玩,终于可以坐上梦寐以求的过山车了。可是,过山车的每一排只有两个座位,而且还有条不成文的规矩,就是每个女生必须找个个男生做partner和她同坐。但是,每个女孩都有各自的想法,举个例子把,Rabbit只愿意和XHD或PQK做partner,Grass只愿意和linle或LL做partner,PrincessSnow愿意和水域浪子原创 2016-07-25 13:53:32 · 297 阅读 · 0 评论 -
HDU 5651 xiaoxin juju needs help [组合数]
Description As we all known, xiaoxin is a brilliant coder. He knew **palindromic** strings when he was only a six grade student at elementry school. This summer he was working at Tencent as an原创 2016-08-09 17:34:30 · 274 阅读 · 0 评论 -
HDU 1083 COURSES 【二分图最大匹配】
Description Consider a group of N students and P courses. Each student visits zero, one or more than one courses. Your task is to determine whether it is possible to form a committee of exactly P s原创 2016-07-27 21:44:24 · 291 阅读 · 0 评论 -
HDU 1576 A/B [扩展欧几里德]
Description 要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973) = 1)。 Input 数据的第一行是一个T,表示有T组数据。 每组数据有两个数n(0 Output 对应每组数据输出(A/B)%9973。 Sample Input 2 1原创 2016-08-05 16:54:40 · 277 阅读 · 0 评论 -
HDU 1222 wolf and rabbit [gcd]
Wolf and Rabbit Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1582 Accepted Submission(s): 735 Problem Description There原创 2016-08-05 20:35:44 · 237 阅读 · 0 评论 -
HDU 2669 Romantic [扩展欧几里得]
Description The Sky is Sprite. The Birds is Fly in the Sky. The Wind is Wonderful. Blew Throw the Trees Trees are Shaking, Leaves are Falling. Lovers Walk passing, and so are You. .....原创 2016-08-05 17:17:51 · 228 阅读 · 0 评论 -
HDU 4027 Can you answer these queries?[区间求和+区间更新]
Description A lot of battleships of evil are arranged in a line before the battle. Our commander decides to use our secret weapon to eliminate the battleships. Each of the battleships can be marked原创 2016-08-16 22:07:59 · 267 阅读 · 0 评论 -
HDU 1358 Period [KMP+循环节]
Description For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the prefix is a periodic string. That is,原创 2016-08-01 16:09:08 · 199 阅读 · 0 评论 -
HDU 3746 Cyclic Nacklace [KMP+循环节]
Description CC always becomes very depressed at the end of this month, he has checked his credit card yesterday, without any surprise, there are only 99.9 yuan left. he is too distressed and thinki原创 2016-07-31 19:17:52 · 236 阅读 · 0 评论 -
HDU 2087 剪花布条 [KMP]
Description 一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案。对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢? Input 输入中含有一些数据,分别是成对出现的花布条和小饰条,其布条都是用可见ASCII字符表示的,可见的ASCII字符有多少个,布条的花纹也有多少种花样。花纹条和小饰条不会超过1000个字符长原创 2016-07-31 16:03:52 · 204 阅读 · 0 评论 -
HDU 1686 Oulipo [KMP]
Description The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e'. He was a member of the Oulipo group. A quote from the book: Tout avait Pair no原创 2016-07-31 15:46:25 · 195 阅读 · 0 评论 -
HDU 1711 Number Sequence [KMP】
Description Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 <= M <= 10000, 1 <= N <= 1000000). Your task is to find a number K which make a[K] = b[1], a原创 2016-07-31 15:44:36 · 258 阅读 · 0 评论 -
HDU1698 Just a Hook [lazy+成段更新]
Description In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same lengt原创 2016-08-15 16:06:11 · 366 阅读 · 0 评论 -
HDU 1233 还是畅通工程 [最小生成树]
Description 某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。 Input 测试输入包含若干测试用例。每个测试用例的第1行给出村庄数目N ( 当N为0时,原创 2016-07-26 14:42:44 · 283 阅读 · 0 评论 -
HDU 2119 Matrix [二分图匹配之最小覆盖]
Description Give you a matrix(only contains 0 or 1),every time you can select a row or a column and delete all the '1' in this row or this column . Your task is to give out the minimum times of原创 2016-07-25 14:46:02 · 304 阅读 · 0 评论 -
HDU 11150 Machine Schedule [二分图之求最小覆盖]
Description As we all know, machine scheduling is a very classical problem in computer science and has been studied for a very long history. Scheduling problems differ widely in the nature of the c原创 2016-07-25 14:30:58 · 180 阅读 · 0 评论 -
hdu 1021 Fibonacci Again
斐波那契的递推; 有规律,但是我打表过了; f[0]=7; f[1]=11; 实际对他们%3 就是 f[0]=1. f[1]=2;正规的斐波那契了; 则有n>2 f[n]=(f[n-1]+f[n-2])%3; 递推出斐波那契数列; 则问输入n,f[n]%3==0 yes . 否则 no; Description There are another kind of原创 2016-02-23 21:39:12 · 238 阅读 · 0 评论 -
HDU 1017 A Mathematical Curiosity
题目: 输入数据N ,代表N组多实例; 输入n,m代表两个数,且 a 如果有a,b,使(a^2+b^2 +m)/(ab)为整数,(既互相取余为0) 则(a,b)为一组数;问输入的数据中,有多少组这样的数据(a,b); Description Given two integers n and m, count the number of pairs of integers (a,原创 2016-02-23 21:20:27 · 355 阅读 · 0 评论 -
HDU1584 蜘蛛牌 [DFS简单题]
这个题一开始难哭,想不通为什么,现在大概理一理,思路如下: 1.一共只有十张牌,所以只是随机排列,并求出其中的距离之和;因为1只能接2,2接3,以此类推; 2.EG:1 4 5 2 3 所以应该先从1--->2,距离 abs = 4 - 1 = 3 ; 3.而且因为需要扫描,所以令初始标记为0,当满足要求则变为1,扫一遍后,再重新置为0,开始搜符合要求的; PS:一开始多有借鉴大大们原创 2016-01-14 21:28:26 · 693 阅读 · 1 评论 -
线段树常见套路
线段树就是一颗二叉树, 在二叉树上建立区间; 所以第一个板子是如何建立一颗树,我喜欢直接建,比较暴力; 宏定义虽然慢,但是很方便; #define lson l,m,rt<<1 #define rson m+1,r,rt void Build(int l,int r,int rt) { if(l==r) { scanf("%d",&MAX[rt]);原创 2016-02-10 14:15:26 · 517 阅读 · 0 评论 -
HDU 1754 I hate it 【线段树简单题】
Description 很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。 Input 本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整原创 2016-02-13 19:16:02 · 291 阅读 · 0 评论 -
HDU2151 【DP】
M为分钟,T为位置,则到A[M][T]的方法为A[M-1][T-1]+A[M-1][T+1]‘ DP的精髓就是找状态方程,因为只有两个方向可以到达目标地点; Description 自从见识了平安夜苹果的涨价后,Lele就在他家门口水平种了一排苹果树,共有N棵。 突然Lele发现在左起第P棵树上(从1开始计数)有一条毛毛虫。为了看到毛毛虫变蝴蝶的过程,Lele在苹果树旁观原创 2016-01-30 17:43:14 · 273 阅读 · 0 评论 -
HDU 1166 敌兵布阵【简单典型的线段树问题】
线段树就是一颗二叉树 不过是区间二叉树。 目前比较板子的就是,建树,区间,查最小值,增添(减少就是负向增添); 所以直接贴代码了: 希望自己可以多理解理解: #include using namespace std ; struct seg//*结构体代替左右区间和当前子节点 { int l; int r; int n; } T[150011]; void原创 2016-02-09 00:53:14 · 277 阅读 · 0 评论