罗书
唐火
开始人工智能之路了!!!
展开
-
poj3468 A Simple Problem with Integers-线段树区间查询,区间修改
DescriptionYou have N integers, A1, A2, … , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the sum of numbers in a given interval.InputThe原创 2021-03-31 19:01:40 · 149 阅读 · 1 评论 -
hdu4911 Inversion-归并排序
解题思路:如果原序列的逆序对数大于交换次数,那么最少的逆序对数量就是原序列逆序对-交换次数。如果原序列的逆序对数小于等于交换次数,那么最少的逆序对数量为0,因为交换次数超过逆序对数,可以把这些逆序对全部消除。代码如下:#include <iostream>using namespace std;const int N = 100010;typedef long long LL;LL cnt = 0;LL a[N];LL w[N];int n, p;void merge.原创 2021-03-28 14:10:41 · 121 阅读 · 0 评论 -
poj2182 Lost Cows-线段树
DescriptionN (2 <= N <= 8,000) cows have unique brands in the range 1…N. In a spectacular display of poor judgment, they visited the neighborhood ‘watering hole’ and drank a few too many beers before dinner. When it was time to line up for their eve原创 2021-03-28 10:16:50 · 131 阅读 · 0 评论 -
poj2182 Lost Cows-暴力
DescriptionN (2 <= N <= 8,000) cows have unique brands in the range 1…N. In a spectacular display of poor judgment, they visited the neighborhood ‘watering hole’ and drank a few too many beers before dinner. When it was time to line up for their eve原创 2021-03-25 22:16:10 · 181 阅读 · 0 评论 -
hdu2648 Shopping-map容器
Problem DescriptionEvery girl likes shopping,so does dandelion.Now she finds the shop is increasing the price every day because the Spring Festival is coming .She is fond of a shop which is called “memory”. Now she wants to know the rank of this shop’s pr原创 2021-03-25 13:12:36 · 149 阅读 · 0 评论 -
poj3981 字符串替换-字符串的基本操作
Description编写一个C程序实现将字符串中的所有"you"替换成"we"Input输入包含多行数据每行数据是一个字符串,长度不超过1000数据以EOF结束Output对于输入的每一行,输出替换后的字符串Sample Inputyou are what you doSample Outputwe are what we do法一代码如下:#include <iostream>using namespace std;const int N = 1010;ch原创 2021-03-25 12:44:25 · 136 阅读 · 0 评论 -
hdu2544 最短路-邻接表+优先队列实现dijkstra
Problem Description在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt。但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要寻找最短的从商店到赛场的路线,你可以帮助他们吗?Input输入包括多组数据。每组数据第一行是两个整数N、M(N<=100,M<=10000),N表示成都的大街上有几个路口,标号为1的路口是商店所在地,标号为N的路口是赛场所在地,M则表示在成都有几条路。N=M=0表示输入结束。接下来M行,每行包括转载 2021-03-25 10:22:11 · 99 阅读 · 0 评论 -
hdu2544 最短路-Floyd算法
Problem Description在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt。但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要寻找最短的从商店到赛场的路线,你可以帮助他们吗?Input输入包括多组数据。每组数据第一行是两个整数N、M(N<=100,M<=10000),N表示成都的大街上有几个路口,标号为1的路口是商店所在地,标号为N的路口是赛场所在地,M则表示在成都有几条路。N=M=0表示输入结束。接下来M行,每行包括原创 2021-03-25 10:06:02 · 112 阅读 · 0 评论 -
hdu1873 看病要排队-优先队列
Problem Description看病要排队这个是地球人都知道的常识。不过经过细心的0068的观察,他发现了医院里排队还是有讲究的。0068所去的医院有三个医生(汗,这么少)同时看病。而看病的人病情有轻重,所以不能根据简单的先来先服务的原则。所以医院对每种病情规定了10种不同的优先级。级别为10的优先权最高,级别为1的优先权最低。医生在看病时,则会在他的队伍里面选择一个优先权最高的人进行诊治。如果遇到两个优先权一样的病人的话,则选择最早来排队的病人。现在就请你帮助医院模拟这个看病过程。Input原创 2021-03-24 18:56:43 · 184 阅读 · 0 评论 -
石子合并-区间dp
设有N堆石子排成一排,其编号为1,2,3,…,N。每堆石子有一定的质量,可以用一个整数来描述,现在要将这N堆石子合并成为一堆。每次只能合并相邻的两堆,合并的代价为这两堆石子的质量之和,合并后与这两堆石子相邻的石子将和新堆相邻,合并时由于选择的顺序不同,合并的总代价也不相同。例如有4堆石子分别为 1 3 5 2, 我们可以先合并1、2堆,代价为4,得到4 5 2, 又合并 1,2堆,代价为9,得到9 2 ,再合并得到11,总代价为4+9+11=24;如果第二步是先合并2,3堆,则代价为7,得到4 7,原创 2021-03-24 13:55:07 · 123 阅读 · 0 评论 -
hdu2602 Bone Collector-01背包问题
Problem DescriptionMany years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , such as dog’s , cow’s , also he went to the grave …The bone collector had a big bag with a volume of V ,an原创 2021-03-24 11:19:10 · 128 阅读 · 0 评论 -
hdu2069 Coin Change-dp
Problem DescriptionSuppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1-cent. We want to make changes with these coins for a given amount of money.For example, if we have 11 cents, then we can make changes with one 10-cent coin an原创 2021-03-24 00:12:10 · 171 阅读 · 0 评论 -
hdu 2069 Coin Change(改)-dp
有5种面值的硬币,即1分,5分,10分,25分,50分。输入一个钱数s,输出组合方案的数量。s<=250,硬币数量不限。代码如下:#include <iostream>using namespace std;const int N = 5;const int Maxm = 251;int dp[Maxm];int m[] = {1, 5, 10, 25, 50};int main() { dp[0] = 1; for (int i = 0; i < N; i原创 2021-03-23 23:56:42 · 113 阅读 · 0 评论 -
打印最少硬币的组合-dp+记录路径
题目:有5种硬币,面值分别为:1,5,10,25,50。数量无限,输入非负整数s,选用硬币,使其和为s。要求输出最少的硬币组合的方案?数据范围:s最大为250.解题思路:有时间再写,可以评论喊一声哦,我怕我忘记了!!!代码如下:#include <iostream>using namespace std;const int N = 5;int m[] = {1, 5, 10, 25, 50};const int Maxm = 251;const int INF = 99原创 2021-03-23 19:53:42 · 297 阅读 · 1 评论 -
最少硬币问题-dp
题目:有5种硬币,面值分别为:1,5,10,25,50。数量无限,输入非负整数s,选用硬币,使其和为s。要求输出最少的硬币组合要多少个硬币?数据范围:s最大为250.解题思路:有时间再写,可以评论喊一声哦,我怕我忘记了!!!代码如下:#include <iostream>using namespace std;const int N = 5;const int Maxm = 251;int m[] = {1, 5, 10, 25, 50};const int INF =原创 2021-03-23 19:38:04 · 120 阅读 · 0 评论 -
今年暑假不AC-贪心
Problem Description“今年暑假不AC?”“是的。”“那你干什么呢?”“看世界杯呀,笨蛋!”“@#$%^&*%…”确实如此,世界杯来了,球迷的节日也来了,估计很多ACMer也会抛开电脑,奔向电视了。作为球迷,一定想看尽量多的完整的比赛,当然,作为新时代的好青年,你一定还会看一些其它的节目,比如新闻联播(永远不要忘记关心国家大事)、非常6+7、超级女生,以及王小丫的《开心辞典》等等,假设你已经知道了所有你喜欢看的电视节目的转播时间表,你会合理安排吗?(目标是能看尽量多的完原创 2021-03-23 12:41:18 · 158 阅读 · 0 评论 -
hdu2553 N皇后问题-dfs回溯剪枝+打表
Problem Description在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。你的任务是,对于给定的N,求出有多少种合法的放置方法。Input共有若干行,每行一个正整数N≤10,表示棋盘和皇后的数量;如果N=0,表示结束。Output共有若干行,每行一个正整数,表示对应输入行的皇后的不同放置数量。Sample Input1850Sample Output19210解题思路:这题我们原创 2021-03-23 12:41:15 · 168 阅读 · 6 评论 -
hdu1312-Red and Black-dfs
Problem DescriptionThere is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can’t move on red tiles, he can move onl原创 2021-03-22 20:38:32 · 131 阅读 · 4 评论 -
搜索(bfs,dfs)易错点-限制条件的选择
Problem DescriptionThere is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can’t move on red tiles, he can move onl原创 2021-03-22 20:05:10 · 246 阅读 · 0 评论 -
hdu1312 Red and Black-bfs
Problem DescriptionThere is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can’t move on red tiles, he can move onl原创 2021-03-22 19:44:22 · 109 阅读 · 0 评论 -
hdu1213 How Many Tables-并查集
Problem DescriptionToday is Ignatius’ birthday. He invites a lot of friends. Now it’s dinner time. Ignatius wants to know how many tables he needs at least. You have to notice that not all the friends know each other, and all the friends do not want to st原创 2021-03-22 16:04:28 · 105 阅读 · 0 评论 -
hdu1276 士兵队列训练问题-list容器
Problem Description某部队进行新兵队列训练,将新兵从一开始按顺序依次编号,并排成一行横队,训练的规则如下:从头开始一至二报数,凡报到二的出列,剩下的向小序号方向靠拢,再从头开始进行一至三报数,凡报到三的出列,剩下的向小序号方向靠拢,继续从头开始进行一至二报数。。。,以后从头开始轮流进行一至二报数、一至三报数直到剩下的人数不超过三人为止。Input本题有多个测试数据组,第一行为组数N,接着为N行新兵人数,新兵人数不超过5000。Output共有N行,分别对应输入的新兵人数,每行输出原创 2021-03-22 15:51:35 · 204 阅读 · 0 评论 -
hdu1062 Text Reverse-stack容器
Problem DescriptionIgnatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you should reverse all the words and then output them.InputThe input contains several test cases. The first line of the input is a原创 2021-03-22 12:08:53 · 87 阅读 · 0 评论 -
hdu4841 圆桌问题-vector容器模拟
Problem Description圆桌上围坐着2n个人。其中n个人是好人,另外n个人是坏人。如果从第一个人开始数数,数到第m个人,则立即处死该人;然后从被处死的人之后开始数数,再将数到的第m个人处死……依此方法不断处死围坐在圆桌上的人。试问预先应如何安排这些好人与坏人的座位,能使得在处死n个人之后,圆桌上围坐的剩余的n个人全是好人。Input多组数据,每组数据输入:好人和坏人的人数n(<=32767)、步长m(<=32767);Output对于每一组数据,输出2n个大写字母,‘G’原创 2021-03-22 10:24:12 · 127 阅读 · 0 评论