
ACM刷题
.
鳳九~
这个作者很懒,什么都没留下…
展开
-
POJ 2255 Tree Recovery
Little Valentine liked playing with binary trees very much. Her favorite game was constructing randomly looking binary trees with capital letters in the nodes.This is an example of one of her creatio...原创 2020-02-05 20:59:22 · 217 阅读 · 0 评论 -
POJ 3641 Pseudoprime numbers
Fermat’s theorem states that for any prime number p and for any integer a > 1, ap = a (mod p). That is, if we raise a to the pth power and divide by p, the remainder is a. Some (but not very many) ...原创 2020-02-05 21:07:55 · 140 阅读 · 1 评论 -
HDU 2594 Simpsons’ Hidden Talents(kmp)
Homer: Marge, I just figured out a way to discover some of the talents we weren’t aware we had.Marge: Yeah, what is it?Homer: Take me for example. I want to find out if I have a talent in politics, ...原创 2019-08-16 17:58:50 · 132 阅读 · 0 评论 -
HDU 2594 Simpsons’ Hidden Talents(kmp)
Homer: Marge, I just figured out a way to discover some of the talents we weren’t aware we had.Marge: Yeah, what is it?Homer: Take me for example. I want to find out if I have a talent in politics, ...原创 2019-07-31 17:18:40 · 95 阅读 · 0 评论 -
HDU 1867 A + B for you again (kmp)
Generally speaking, there are a lot of problems about strings processing. Now you encounter another such problem. If you get two strings, such as “asdf” and “sdfg”, the result of the addition between ...原创 2019-07-31 16:08:06 · 117 阅读 · 0 评论 -
POJ 1961 Period(kmp)
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, for each i (2 ...原创 2019-07-31 09:29:17 · 116 阅读 · 0 评论 -
HDU 1702 ACboy needs your help again!(单链表写法)
ACboy was kidnapped!!he miss his mother very much and is very scare now.You can’t image how dark the room he was put into is, so poor ????.As a smart ACMer, you want to get ACboy out of the monster’s l...原创 2019-09-09 13:58:30 · 186 阅读 · 0 评论 -
HDU - 1022 Train Problem I(栈)
As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to school by train(because the trains in the Ignatius Train Station is the fastest all over t...原创 2019-08-11 16:47:14 · 99 阅读 · 0 评论 -
单链表的创建、插入删除和查询
适合初学者的代码刚开始接触这个东西是感觉有点懵逼,但是学完之后,感觉其实就是把原来放在数组中的元素,变成放在一个链表中了,别的操作几乎相同。头插法创建链在遍历时元素输出的顺序与原来输进去的元素的顺序是相反的,而尾插则是相同的。例如输进去的是1 2 3 4 5。头插遍历是:5 4 3 2 1。尾插遍利是:1 2 3 4 5。这是我写的代码希望对那些初学链表的兄弟姐妹们有帮助。#incl...原创 2019-07-27 11:51:35 · 1487 阅读 · 0 评论 -
双链表的创建、插入、删除与查询 C语言
适合初学者代码#include<stdio.h>#include<stdlib.h>struct node{int data;struct node *next; struct node *prior;};typedef struct node *LinkList;void create(LinkList head,LinkList tail,int n...原创 2019-07-16 10:48:08 · 1425 阅读 · 0 评论 -
POJ 1083 Moving Tables
The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure.The floor has 200 rooms each on the north side and south side along the corri...原创 2020-02-15 20:20:46 · 240 阅读 · 1 评论 -
POJ 1700 Crossing River
A group of N people wishes to go across a river with only one boat, which can at most carry two persons. Therefore some sort of shuttle arrangement must be arranged in order to row the boat back and f...原创 2020-02-05 21:04:34 · 149 阅读 · 0 评论 -
HDU-2546-饭卡(dp)
电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额。如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够)。所以大家都希望尽量使卡上的余额最少。某天,食堂中有n种菜出售,每种菜可购买一次。已知每种菜的价格以及卡上的余额,问最少可使卡上的余额为多少。Input多组数据。对于每组数据:第一行为正整数n,表示菜的...原创 2020-02-05 20:46:56 · 262 阅读 · 0 评论 -
HDU-1114 Piggy-Bank —DP最小装载
Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea behind is simple...原创 2020-02-03 21:29:31 · 226 阅读 · 0 评论 -
HDU 2191 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活(多重背包)
急!灾区的食物依然短缺!为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买。请问:你用有限的资金最多能采购多少公斤粮食呢?后记:人生是一个充满了变数的生命过程,天灾、人祸、病痛是我们生命历程中不可预知的威胁。月有阴晴圆缺,人有旦夕祸福,未来对于我们而言是一个未知数。那么,我...原创 2019-08-12 08:34:44 · 98 阅读 · 0 评论 -
POJ1976A Mini Locomotive(dp 01背包)
A train has a locomotive that pulls the train with its many passenger coaches. If the locomotive breaks down, there is no way to pull the train. Therefore, the office of railroads decided to distribut...原创 2019-08-11 15:50:19 · 342 阅读 · 0 评论 -
POJ 2524 Ubiquitous Religions(并查集)
There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out how many different religions students in your university beli...原创 2020-02-15 20:30:05 · 193 阅读 · 1 评论 -
Supermarket POJ - 1456 (贪心+并查集)
A supermarket has a set Prod of products on sale. It earns a profit px for each product x∈Prod sold by a deadline dx that is measured as an integral number of time units starting from the moment the s...原创 2020-01-21 10:15:39 · 244 阅读 · 1 评论 -
HDU 1829 A Bug's Life
BackgroundProfessor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different genders and that they only interact with bugs of the opposite gende...原创 2019-09-27 16:14:17 · 131 阅读 · 0 评论 -
POJ 2236 Wireless Network(并查集)
An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked, all computers in the n...原创 2019-08-08 09:33:32 · 92 阅读 · 0 评论 -
POJ 2492 A Bug's Life(并查集的变形)
BackgroundProfessor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different genders and that they only interact with bugs of the opposite gende...原创 2019-08-07 17:49:26 · 158 阅读 · 0 评论 -
HDU 6213 Chinese Zodiac
The Chinese Zodiac, known as Sheng Xiao, is based on a twelve-year cycle, each year in the cycle related to an animal sign. These signs are the rat, ox, tiger, rabbit, dragon, snake, horse, sheep, mon...原创 2020-03-18 17:12:27 · 153 阅读 · 1 评论 -
HDU - 1263- 水果(map)
夏天来了好开心啊,呵呵,好多好多水果Joe经营着一个不大的水果店.他认为生存之道就是经营最受顾客欢迎的水果.现在他想要一份水果销售情况的明细表,这样Joe就可以很容易掌握所有水果的销售情况了.Input第一行正整数N(0<N<=10)表示有N组测试数据.每组测试数据的第一行是一个整数M(0<M<=100),表示工有M次成功的交易.其后有M行数据,每行表示一次交易,由...原创 2019-11-09 15:31:24 · 144 阅读 · 0 评论 -
POJ - 3096 Surprising Strings
The D-pairs of a string of letters are the ordered pairs of letters that are distance D from each other. A string is D-unique if all of its D-pairs are different. A string is surprising if it is D-uni...原创 2019-11-09 15:04:02 · 165 阅读 · 0 评论 -
混合牛奶(贪心)
题目描述对于一群要互送礼物的朋友,你要确定每个人送出的礼物比收到的多多少(and vice versa for those who view gift giving with cynicism)。在这一个问题中,每个人都准备了一些钱来送礼物,而这些钱将会被平均分给那些将收到他的礼物的人。然而,在任何一群朋友中,有些人将送出较多的礼物(可能是因为有较多的朋友),有些人有准备了较多的钱。给出一...原创 2019-11-01 15:21:41 · 335 阅读 · 0 评论 -
HDU 1412 {A} + {B}
给你两个集合,要求{A} + {B}.注:同一个集合中不会有两个相同的元素.Input每组输入数据分为三行,第一行有两个数字n,m(0<n,m<=10000),分别表示集合A和集合B的元素个数.后两行分别表示集合A和集合B.每个元素为不超出int范围的整数,每个元素之间有一个空格隔开.Output针对每组数据输出一行数据,表示合并后的集合,要求从小到大输出,每个元素之间有一个...原创 2019-08-11 16:32:23 · 113 阅读 · 0 评论 -
POJ 3050 Hopscotch(dfs暴力)
The cows play the child’s game of hopscotch in a non-traditional way. Instead of a linear set of numbered boxes into which to hop, the cows create a 5x5 rectilinear grid of digits parallel to the x an...原创 2020-02-15 20:25:58 · 262 阅读 · 1 评论 -
POJ 3984-迷宫问题 (dfs)
定义一个二维数组:int maze[5][5] = {0, 1, 0, 0, 0,0, 1, 0, 1, 0,0, 0, 0, 0, 0,0, 1, 1, 1, 0,0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。Input一个5 × 5的二维数组,表示一个迷宫。数据保...原创 2020-02-03 21:45:45 · 233 阅读 · 1 评论 -
HDU - 1251 统计难题
Ignatius最近遇到一个难题,老师交给他很多单词(只有小写字母组成,不会有重复的单词出现),现在老师要他统计出以某个字符串为前缀的单词数量(单词本身也是自己的前缀).Input输入数据的第一部分是一张单词表,每行一个单词,单词的长度不超过10,它们代表的是老师交给Ignatius统计的单词,一个空行代表单词表的结束.第二部分是一连串的提问,每行一个提问,每个提问都是一个字符串.注意:本题...原创 2019-08-11 16:39:55 · 196 阅读 · 0 评论 -
HDU 1010 Tempter of the Bone(dfs+剪枝)
The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked it up, the maze began to shake, and the doggie could feel the ground sinking. He realized that the bone ...原创 2019-08-01 14:28:37 · 335 阅读 · 10 评论 -
HDU - 1016 Prime Ring Problem(dfs)
A ring is compose of n circles as shown in diagram. Put natural number 1, 2, …, n into each circle separately, and the sum of numbers in two adjacent circles should be a prime.Note: the number of fir...原创 2019-07-31 09:08:31 · 108 阅读 · 0 评论 -
ZOJ - 1649 Rescue(dfs)
Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, ROADs, and GUARDs in the prison.Angel’s friends want to ...原创 2019-07-31 08:49:48 · 238 阅读 · 0 评论 -
HDU - 1548 A strange lift(dfs)
There is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N) on every floor.The lift have just two buttons: up and down.When you at floor i,if...原创 2019-07-28 18:12:37 · 156 阅读 · 0 评论 -
POJ 2243 Knight Moves bfs
A friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight movesthat visits each square of a given set of n squares on a chessbo...原创 2019-07-27 15:08:54 · 120 阅读 · 0 评论 -
POJ 2031 Building a Space Station(Kruscal算法)
You are a member of the space station engineering team, and are assigned a task in the construction process of the station. You are expected to write a computer program to complete the task.The space...原创 2019-08-15 08:56:18 · 168 阅读 · 0 评论 -
HDU1102 Constructing Roads(prim)
You are a member of the space station engineering team, and are assigned a task in the construction process of the station. You are expected to write a computer program to complete the task.The space...原创 2019-08-14 17:51:34 · 100 阅读 · 0 评论 -
POJ2485 Highways(Kruskal算法)
The island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has a very poor system of public highways. The Flatopian government is aware of this problem and has already constructed a numb...原创 2019-08-14 17:44:12 · 151 阅读 · 0 评论 -
POJ 3026 Borg Maze(bfs+prim)
The Borg is an immensely powerful race of enhanced humanoids from the delta quadrant of the galaxy. The Borg collective is the term used to describe the group consciousness of the Borg civilization. E...原创 2019-08-14 17:34:39 · 125 阅读 · 0 评论 -
POJ 1797 Silver Cow Party(Dijkstra)
One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1…N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total of M (1 ≤ M ≤ 100,000) unidirectional (one-way roa...原创 2019-08-11 15:33:43 · 110 阅读 · 0 评论 -
POJ 2387 Til the Cows Come Home (Dijkstra)
Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she wants to get b...原创 2019-07-31 16:55:10 · 88 阅读 · 0 评论