![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
训练题目
楚仙子
我只是想学算法
展开
-
CSU-ACM2019寒假训练2-B - Just Bsearch
这道题目也是二分的一个方法,主要就是减少算法复杂度的思想,先合并,再二分~然后对于二分的循环条件的判断,这个链接还是有用滴~如何写出正确的二分查找?——利用循环不变式理解二分查找及其变体的正确性以及构造方式题目如下:Give you three sequences of numbers A, B, C, then we give you a number X. Now you need t...原创 2019-01-23 20:12:54 · 165 阅读 · 0 评论 -
CSU-ACM2019寒假集训 DP初步-E - Bone Collector
这道题目就开始01背包问题了,emmmm,刚开始确实很难懂o(╥﹏╥)o题目:Many 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 h...原创 2019-01-28 21:29:07 · 257 阅读 · 0 评论 -
Connections in Galaxy War(逆向并查集)
题目In order to strengthen the defense ability, many stars in galaxy allied together and built many bidirectional tunnels to exchange messages. However, when the Galaxy War began, some tunnels were des...原创 2019-08-02 21:50:50 · 142 阅读 · 0 评论 -
逃生(反向拓扑排序)
题目糟糕的事情发生啦,现在大家都忙着逃命。但是逃命的通道很窄,大家只能排成一行。现在有n个人,从1标号到n。同时有一些奇怪的约束条件,每个都形如:a必须在b之前。同时,社会是不平等的,这些人有的穷有的富。1号最富,2号第二富,以此类推。有钱人就贿赂负责人,所以他们有一些好处。负责人现在可以安排大家排队的顺序,由于收了好处,所以他要让1号尽量靠前,如果此时还有多种情况,就再让2号尽量靠前,如果还...原创 2019-08-03 09:03:56 · 466 阅读 · 0 评论 -
威尔逊定理A
题目Tina Town is a friendly place. People there care about each other.Tina has a ball called zball. Zball is magic. It grows larger every day. On the first day, it becomes 1 time as large as its origi...原创 2019-08-03 09:31:47 · 139 阅读 · 0 评论 -
威尔逊定理B
题目The math department has been having problems lately. Due to immense amount of unsolicited automated programs which were crawling across their pages, they decided to put Yet-Another-Public-Turing-Te...原创 2019-08-03 09:49:06 · 381 阅读 · 0 评论 -
中国剩余定理-(POJ - 1006)
题目Some people believe that there are three cycles in a person’s life that start the day he or she is born. These three cycles are the physical, emotional, and intellectual cycles, and they have perio...原创 2019-08-03 10:14:31 · 392 阅读 · 0 评论 -
一个简单的询问 (HYSBZ - 5016)
题目给你一个长度为N的序列ai,1≤i≤N和q组询问,每组询问读入l1,r1,l2,r2,需输出get(l,r,x)表示计算区间[l,r]中,数字x出现了多少次。Input第一行,一个数字N,表示序列长度。第二行,N个数字,表示a1~aN第三行,一个数字Q,表示询问个数。第4~Q+3行,每行四个数字l1,r1,l2,r2,表示询问。N,Q≤50000N1≤ai≤N1≤l1≤r...原创 2019-08-08 22:51:54 · 206 阅读 · 0 评论 -
K-th Closest Distance(HDU - 6621)
题目You have an array: a1, a2, , an and you must answer for some queries.For each query, you are given an interval [L, R] and two numbers p and K. Your goal is to find the Kth closest distance betwee...原创 2019-08-08 23:17:04 · 147 阅读 · 0 评论 -
Bounce 弹飞绵羊 (HYSBZ - 2002)
题目某天,Lostmonkey发明了一种超级弹力装置,为了在他的绵羊朋友面前显摆,他邀请小绵羊一起玩个游戏。游戏一开始,Lostmonkey在地上沿着一条直线摆上n个装置,每个装置设定初始弹力系数ki,当绵羊达到第i个装置时,它会往后弹ki步,达到第i+ki个装置,若不存在第i+ki个装置,则绵羊被弹飞。绵羊想知道当它从第i个装置起步时,被弹几次后会被弹飞。为了使得游戏更有趣,Lostmonke...原创 2019-08-09 09:09:54 · 71 阅读 · 0 评论 -
小Z的袜子(hose)(HYSBZ - 2038)
题目作为一个生活散漫的人,小Z每天早上都要耗费很久从一堆五颜六色的袜子中找出一双来穿。终于有一天,小Z再也无法忍受这恼人的找袜子过程,于是他决定听天由命……具体来说,小Z把这N只袜子从1到N编号,然后从编号L到R(L 尽管小Z并不在意两只袜子是不是完整的一双,甚至不在意两只袜子是否一左一右,他却很在意袜子的颜色,毕竟穿两只不同色的袜子会很尴尬。你的任务便是告诉小Z,他有多大的概率抽到两只颜色...原创 2019-08-09 09:40:13 · 92 阅读 · 0 评论 -
玩具装箱 TOY(HNOI2008)
题目P教授要去看奥运,但是他舍不下他的玩具,于是他决定把所有的玩具运到北京。他使用自己的压缩器进行压缩,其可以将任意物品变成一堆,再放到一种特殊的一维容器中。P教授有编号为1…N的N件玩具,第i件玩具经过压缩后变成一维长度为Ci.为了方便整理,P教授要求在一个一维容器中的玩具编号是连续的。同时如果一个一维容器中有多个玩具,那么两件玩具之间要加入一个单位长度的填充物,形式地说如果将第i件玩具...原创 2019-08-09 15:13:16 · 121 阅读 · 0 评论 -
Bomb(HDU - 5934)
题目There are N bombs needing exploding.Each bomb has three attributes: exploding radius riri, position (xi,yi) and lighting-cost ci which means you need to pay cici cost making it explode.If a un-li...原创 2019-08-14 15:02:06 · 145 阅读 · 0 评论 -
征途(bzoj 4518)
题目Pine开始了从S地到T地的征途。从S地到T地的路可以划分成n段,相邻两段路的分界点设有休息站。Pine计划用m天到达T地。除第m天外,每一天晚上Pine都必须在休息站过夜。所以,一段路必须在同一天中走完。Pine希望每一天走的路长度尽可能相近,所以他希望每一天走的路的长度的方差尽可能小。帮助Pine求出最小方差是多少。设方差是v,可以证明,v×m^ 2是一个整数。为了避免精度误差...原创 2019-08-10 09:30:59 · 190 阅读 · 0 评论 -
Popular Cows(POJ2186)
题目Every cow’s dream is to become the most popular cow in the herd. In a herd of N (1 <= N <= 10,000) cows, you are given up to M (1 <= M <= 50,000) ordered pairs of the form (A, B) that t...原创 2019-08-14 16:19:02 · 119 阅读 · 0 评论 -
Watching Fireworks is Fun(CF372C)
题目A festival will be held in a town’s main street. There are n sections in the main street. The sections are numbered 1 through n from left to right. The distance between each adjacent sections is 1....原创 2019-08-10 14:25:14 · 551 阅读 · 1 评论 -
仓库建设(HYSBZ - 1096)
题目L公司有N个工厂,由高到底分布在一座山上。如图所示,工厂1在山顶,工厂N在山脚。由于这座山处于高原内陆地区(干燥少雨),L公司一般把产品直接堆放在露天,以节省费用。突然有一天,L公司的总裁L先生接到气象 部门的电话,被告知三天之后将有一场暴雨,于是L先生决定紧急在某些工厂建立一些仓库以免产品被淋坏。由于地形的不同,在不同工厂建立仓库的费用可能是不同的。第i个工厂目前已有成品Pi件,在第i...原创 2019-08-11 16:29:44 · 107 阅读 · 0 评论 -
Kth number(HDU2665)
题目Give you a sequence and ask you the kth big number of a inteval.InputThe first line is the number of the test cases.For each test case, the first line contain two integer n and m (n, m <= 100...原创 2019-08-12 10:39:36 · 189 阅读 · 0 评论 -
CSU-ACM2019寒假集训 DP初步-I - 石子归并
这道题就是区间dp的入门题啦~果然在集训对我而言就是学会模板题o(╥﹏╥)o,加油ヾ(◍°∇°◍)ノ゙题目:现在有n堆石子,第i堆有ai个石子。现在要把这些石子合并成一堆,每次只能合并相邻两个,每次合并的代价是两堆石子的总石子数。求合并所有石子的最小代价。Input第一行包含一个整数T(T<=50),表示数据组数。每组数据第一行包含一个整数n(2<=n<=100),表示...原创 2019-01-28 20:54:01 · 160 阅读 · 0 评论 -
CSU-ACM2019寒假集训 DP初步-C - Longest Ordered Subsequence
依旧水题,不过开心,O(∩_∩)O,毕竟通过这三道题让自己的信心还是回来一点的啦~题目:A numeric sequence of ai is ordered if a1 < a2 < … < aN. Let the subsequence of the given numeric sequence ( a1, a2, …, aN) be any sequence ( ai1...原创 2019-01-28 20:38:27 · 150 阅读 · 0 评论 -
CSU-ACM2019寒假集训 DP初步-B - Common Subsequence
emmmm依旧水题啦,不过呢,对自己还是有很大的帮助啦,毕竟菜o(╥﹏╥)o题目:A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = &lt; x1, x2, …, xm &gt; another seq...原创 2019-01-28 20:27:25 · 174 阅读 · 0 评论 -
CSU-ACM2019寒假训练2-C - Just Bsearch
这道题目和B题差不多,也是成两部分,不过四个数组,就两两合并,再以一个二分来暴力查找即可,不过有一点点小技巧在中间~题目如下:The SUM problem can be formulated as follows: given four lists A, B, C, D of integer values, compute how many quadruplet (a, b, c, d ) ...原创 2019-01-23 20:23:21 · 232 阅读 · 0 评论 -
CSU-ACM2019寒假训练2-D - Maximize the minimum
这个题目就是最小值最大化的问题(也就是说能去的最小值的最大值)~题目Farmer John has built a new long barn, with N (2 <= N <= 100,000) stalls. The stalls are located along a straight line at positions x1,…,xN (0 <= xi <= ...原创 2019-01-23 21:20:26 · 421 阅读 · 0 评论 -
CSU-ACM2019寒假训练2-J - Minimize the maximum
这个题目和D题一样,都是最小值的最大化,自己熟悉熟悉练练手,尤其是判断~题目作为老人的小明非常忧伤,因为他马上要被流放到本部去了,住进全左家垅最有历史感的11舍真是一件非常荣幸的事情。搬行李是个体力活,小明发现自己的行李太多啦,所以他决定去买很多个袋子来装走。到了超市的小明发现,不同大小的袋子居然价格一样???虽然买最大的自然最赚,但是小明是名远近闻名的环保人士,他觉得袋子只要能装下他的行李...原创 2019-01-23 21:41:01 · 158 阅读 · 0 评论 -
CSU-ACM2019寒假训练2-H - Just Trisearch
这个题其实是三分,但是我按照数学方法来做了,至于三分用的很少,要是感兴趣可以去找找其他的博客,给个链接~三分的用法详细说明题目:Now, here is a fuction:F(x) = 6 * x7+8*x6+7x3+5*x2-yx (0 &lt;= x &lt;=100)Can you find the minimum value when x is between 0 and 10...原创 2019-01-24 00:29:07 · 227 阅读 · 0 评论 -
CSU-ACM2019寒假集训比赛1-A - 应该是一道签到题
这个题目看标题就知道啦,为了完整度,还是写下啦,╮(╯-╰)╭题目:You have unlimited number of coins with values 1,2,…,n. You want to select some set of coins having the total value of S。It is allowed to have multiple coins with ...原创 2019-01-24 22:58:09 · 256 阅读 · 0 评论 -
CSU-ACM2019寒假训练1-B - 这就是例题
写这篇博客来进行复习和巩固吧,以及自己的思路和困惑,来给自己留着复习吧,直接看题目吧_(:з)∠)_“Yakexi, this is the best age!” Dong MW works hard and get high pay, he has many 1 Jiao and 5 Jiao banknotes(纸币), some day he went to a bank and chan...原创 2019-01-21 21:36:26 · 196 阅读 · 0 评论 -
CSU-ACM2019寒假训练1-C -经典简单题
这个题目也是贪心的一个经典了,自己学着点,(ง •_•)ง!!题目:“今年暑假不AC?”“是的。”“那你干什么呢?”“看世界杯呀,笨蛋!”“@#$%^&*%…”确实如此,世界杯来了,球迷的节日也来了,估计很多ACMer也会抛开电脑,奔向电视了。作为球迷,一定想看尽量多的完整的比赛,当然,作为新时代的好青年,你一定还会看一些其它的节目,比如新闻联播(永远不要忘记关心国家大事)...原创 2019-01-21 21:48:33 · 195 阅读 · 0 评论 -
CSU-ACM2019寒假训练1-D - 有点易错题
这一篇中间对重复部分的判断很好!!值得学习一下(。・∀・)ノ题目:FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arranges his cows in a line and herds them...原创 2019-01-21 23:30:45 · 164 阅读 · 0 评论 -
CSU-ACM2019寒假训练1-E - 可能简单题
这道题也是贪心算法里面的经典例子,好好学习一下-——轴上有n个闭区间[ai,bi],选择尽量少的区间覆盖一条指定线段[s,t]。(类似)o( ̄▽ ̄)o题目:Saruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, S...原创 2019-01-21 23:53:14 · 170 阅读 · 0 评论 -
CSU-ACM2019寒假训练1-F - 经典经典题
这道题和之前B题的找最少钞票有相似之处,和洛谷的合并果子也是一类的,运用了逆向思维以及STL中的优先队列,要好好学习一下 o( ̄┰ ̄*)ゞ题目:Farmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (...原创 2019-01-22 00:19:44 · 303 阅读 · 0 评论 -
CSU-ACM2019寒假训练1-G - 相当简单题
这道题相当不错欸,大数字运算的处理方式,学到了(ง •_•)ง题目:One of the first users of BIT’s new supercomputer was Chip Diller. He extended his exploration of powers of 3 to go from 0 to 333 and he explored taking various sum...原创 2019-01-22 00:32:29 · 299 阅读 · 0 评论 -
CSU-ACM2019寒假训练1-J - 真的简单题
这个题目就是水题,一道模拟题在输入时判断即可(虽然水,但是还是有必要练习自己的码力),不过自己做的时候被第一个样例给坑了,以为这个就是判断的 ̄へ ̄题目:Bash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbas...原创 2019-01-22 00:49:59 · 213 阅读 · 0 评论 -
CSU-ACM2019寒假训练DFS&BFS-B - Prime Ring Problem
这道题虽然是个模板题,但是毕竟是学新的知识,给自己一个巩固新知识的机会吧~O(∩_∩)O题目: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 c...原创 2019-01-27 23:25:37 · 164 阅读 · 0 评论 -
CSU-ACM2019寒假集训比赛2-A - Asteroids!
这场比赛就AC这一道题,真的好惭愧,dfs和bfs都没学好,尤其是bfs,去看dfs都没时间学bfs,然后就很难受,考试学习bfs,然后勉强A了这道题≡(▔﹏▔)≡题目:You’re in space.You want to get home.There are asteroids.You don’t want to hit them.InputInput to this probl...原创 2019-01-28 00:02:15 · 162 阅读 · 0 评论 -
CSU-ACM2019寒假训练1-I - 易错简单题
这个题目就是看懂题意,暴力枚举就可以了ヾ(•ω•`)o题目:Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu’s Lab. Since Bash is Professor Zulu’s favourite...原创 2019-01-23 00:05:35 · 154 阅读 · 0 评论 -
CSU-ACM2019寒假训练2-A - Just Bsearch
这道题是二分训练的第一道题,虽然很简单,但是我还是很蠢的wa了几次,对于这种有精度要求的题目要在while循环里面判断,对于输出的左端点还是右端点以及中间值,这里有一篇博客挺不错的(虽然不是主要讲这个)~~手写STL以及循环里面的判断方法自己复习的时候去看看,这样对于二分的理解好点题目:Now,given the equation 8x^4 + 7x^3 + 2x^2 + 3x + 6 =...原创 2019-01-23 00:21:09 · 168 阅读 · 0 评论 -
CSU-ACM2019寒假集训 DP初步-A - 数字三角
好吧,╮(╯▽╰)╭,实在做不下去了,来吧今天学的内容来巩固一下,dp初步~,将自己的想法写出来,算作一种提升吧 (:з」∠)题目:下图是个数字三角,请编写一个程序计算从顶部至底部某处一条路径,使得该路径所经过的数字总和最大。 7 3 8 8 1 0 2...原创 2019-01-28 20:03:43 · 141 阅读 · 0 评论 -
Sequence II(HDU - 5919)
题目Mr. Frog has an integer sequence of length n, which can be denoted as a1,a2,⋯,an.There are m queries.In the i-th query, you are given two integers lili and riri. Consider the subsequence ali,ali+1...原创 2019-08-13 10:07:08 · 206 阅读 · 0 评论