vj
DS_HY
这个作者很懒,什么都没留下…
展开
-
Frogs HDU - 5514 (容斥+gcd)(注意容斥操作)
FrogsHDU - 5514;题意有一堆青蛙,一开始都在0点,然后有一堆圈成一圈的石子,石子的编号是从0-m-1的然后青蛙只能顺时针跳,每个青蛙可以一次跳a[i]格,然后所有青蛙都这样一直跳下去然后问你,这些青蛙踩过的石子的编号和是多少?思路规律发现,对于第i只青蛙,他跳过的格子,一定是m中gcd(a[i],m)的倍数,后来我们觉得是容斥寻原创 2017-10-15 20:41:01 · 244 阅读 · 0 评论 -
G - The Debut Album URAL - 2018(dp)
Pop-group “Pink elephant” entered on recording their debut album. In fact they have only two songs: “My love” and “I miss you”, but each of them has a large number of remixes.The producer of t原创 2017-05-14 21:23:29 · 251 阅读 · 0 评论 -
POJ - 3126 D - Prime Path(bfs)
software gurus, do you? — In fact, I do. You see, there is this programming contest going on... Help the prime minister to find the cheapest prime path between any two given four-digit primes! The f原创 2017-05-23 22:18:00 · 306 阅读 · 0 评论 -
G - Parenthesis (CSU - 1809) 湖南省赛平衡串交换(线段树+RMQ)
找了半天的规律 发现居然是这样。。序列中第i个字符是 ‘(‘, pre[i]=pre[i]+1;序列中第i个字符是 ‘)’, pre[i]=pre[i]−1;这样, 又因为最初的序列是平衡的。当序列不“平衡”当且仅当存在一个数k,使得pre[k]0(1≤k≤N)。只需要用线段树或者RMQ维护区间最小值。 当将第a个字符与第b个字符交换(假定ab),如果第bu原创 2017-04-21 20:42:08 · 418 阅读 · 0 评论 -
HDU - 5707(简单dp)
abcdefadebcf//yesabcdefabecdf//no问一个串是否可以是另外两个串组成,我一开始用的队列以为只要从头开始找就好,然后发现会有一样的情况,这个无法处理,然后就用了dfs会超时,看题解之后知道原来这是个dp啊,我真是个傻子在dp[i][j],里面存值,就是说 c的前i+j个 能不能由a的前i个和b的前j个构成只要一个不行即全错原创 2017-05-03 22:11:11 · 1122 阅读 · 0 评论 -
组队赛2(B/G——Ancient Go)HDU - 5546 (dfs搜索)
Sample Input1.......xo....................x.......xox....x.o.o...xo..o...........xxxo....xooo.Sample OutputCase #1: Can kill in one move!!!Case #2: Can not kill in one move!!!原创 2017-04-05 20:26:56 · 467 阅读 · 0 评论 -
A - Pen Counts HDU - 4486(数学题)
Chicken farmer Xiaoyan is getting three new chickens, Lucy, Charlie and CC. She wants to build a chicken pen so that each chicken has its own, unobstructed view of the countryside. The pen will have t原创 2017-04-18 19:27:42 · 363 阅读 · 0 评论 -
(组队赛E/F Number of Connected Components )UVALive - 7638 (并查集)
题意没读懂,,,,,最后知道了,就是在所有给你的数据当中,只要是存在倍数关系的就连为一体,即使是2和3应为如果有6的话,2与6有关系,3与6有关系那么2与3 也是有关系的那就为一组,最后问你能够分成几组。。。真无奈,这个题用一个并查集来联合所有的数据,然后再提前打好表来提前处理庞大的数据防止超时,将每个数的因子存到一个集合中去,当这个数出现在数据中时就将它所有数据处理好,并集,但注...原创 2017-04-05 22:16:05 · 578 阅读 · 0 评论 -
HDU - 4489(The King’s Ups and Downs (国王的游戏 高高低低排序))(dp)
。。。就是一群数 必须按照高低高低高低 或者低高低高...的方式排列The king has guards of all different heights. Rather than line them up in increasing or decreasing height order, he wants to line them up so each guard is either sh原创 2017-04-17 20:21:36 · 805 阅读 · 0 评论 -
组队赛3-B ,HDU 4961 Boring Sum(数学题)
kj点击打开链接其实是求,这一串数中的,每一个数左方为此数倍数的的最大下标对顶的数与右方为此倍数的最小下标对应的数的累加和#include #include #include #include#includeusing namespace std;#define maxn 100010vectorq[maxn];int a[maxn];int t[maxn];//原创 2017-04-02 22:28:00 · 323 阅读 · 0 评论 -
数读9*9 个人训练赛/ G/F ——POJ - 3074 (DLK)
本来以为跟之前的做的一个4*4一样的一个题目,用普通的dfs去解决,但是开始dfs会输出各个答案,在加入flag之后使他停止在输出一组上,但是还是超时超时代码#include #includeusing namespace std;int vis[15][15];char tu[15][15];int ju(int r,int l){ for(int i=0;i<9;i原创 2017-04-10 11:27:01 · 892 阅读 · 0 评论 -
校赛 A字符串“水题” (状态压缩)
问题 A: 字符串“水”题时间限制: 1 Sec 内存限制: 128 MB提交: 82 解决: 20[提交][状态][讨论版]题目描述给出一个长度为n的字符串(1输入第一行一个正整数T,表示数据组数(1 接下来T行,每行有一个只包含小写字母的字符串。 输出每个答案输出满足要求字符串个数。每个答案占一行。 样例输原创 2017-04-27 12:05:09 · 311 阅读 · 0 评论 -
UVA - 11181 (bfs)
、题目网址‘点击打开链接你会发现这3 20.100.200.305 10.100.100.100.100.100 0Sample OutputCase 1:0.4130430.7391300.847826Case 2:0.2000000.200原创 2017-07-26 20:57:27 · 168 阅读 · 0 评论 -
B - Leading and Trailing LightOJ - 1282(数学加快速幂)
简直是可怕,这个题,居然是用double。。简直是神操作,是我太思维僵化了;居然想着只取前四位然后乘,寻找循环规律;题目网址点击打开链接对于前三位abc的求法,让我直接饮用大佬的解析后三位直接用快数幂取余可以求出前三位我们可以将n^k转化成a.bc * 10^m,这样abc就是前三位了,n^k = a.bc * 10^m即lg(n^k) = lg(a.bc *原创 2017-07-22 22:57:14 · 212 阅读 · 0 评论 -
HDU - 3746 (kmp)(重点在于string 作为局部变量是错的)
用kmp的next数组求出最小重复 子串的长度然后末尾缺少长度数的即是答案一开始我还是不太会kmp,但是看了题解之后敲出了wa了,wa的我一脸懵逼,无奈跟明明是但是有个很玄学的问题,string作为局部变量是错的,但是全局就是对的,神奇,难受,不懂为啥Wa#include #include#include#includeusing namespac原创 2017-07-22 14:23:18 · 190 阅读 · 0 评论 -
HDU - 1010(dfs +奇偶剪枝)
xdd点击打开链接(si,ji)、(h,w)分别为起点终点坐标。我们可使用的两种剪枝方案是:如果所给的时间(步数) t 小于最短步数path,那么一定走不到。若满足t>path。但是如果能在恰好 t 步的时候,走到出口处。那么(t-path)必须是二的倍数。关于第二种方案的解释:这种方案学名为“奇偶剪枝”。我们已知了最短的步数就是直角三角形的两条直角边,实际上的路径却不原创 2017-07-08 23:01:46 · 237 阅读 · 0 评论 -
HDU - 2102(bfs)
这个题目题意有问题。按道理说在T时刻到达,奇偶剪枝后的情况是符合的,,,,突然想到,他似乎是可以停的;莫不是因为这。。。。用的dfs超时了,然后剪枝之后就wa了不过最大的wa点在于,#之后的传送,cnt应该也是+1的,因为他是 从前一步挪过来的;而我一直没有加1就是错在了这里;有一个注意点就是# 和# 之间的传送,出现这种情况是错误的原创 2017-07-12 17:48:59 · 354 阅读 · 0 评论 -
CodeForces - 298A(雪地走步)
奇妙的一个题 最后一轮的A点击打开链接我把题目看错了!,请zzh仔细阅读红色字体部分!!!There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 ton from left to right. If one moves from the原创 2017-07-01 12:26:05 · 485 阅读 · 0 评论 -
C - Coach CodeForces - 300B(并查集)
吐血三升,早知道我就一心的去搞这个题目了,补了十几分钟就AC 完全没有问题gg思密达 ,就是写的长了点但是思路还是比较简单的,就是判断条件多就是用了一个并查集,然后把相同集合的放在一起看来题目的取舍是一门很深的学问,有的时候要相信自己,不要跟着别人跑人云亦云,做出来多的题目可能是简单,但是有的时候不如这种虽然写起来麻烦,但是自己已经有数的题目,看你的选择喽,选对了就赢,原创 2017-07-01 12:33:36 · 317 阅读 · 0 评论 -
垃圾D题 啊啊啊啊CodeForces - 402B
垃圾 垃圾啊!!!!这么水的一题应该分分钟搞定的错了6次一直往下掉感觉跟脑子有问题一样一直在检查代码,看题意,傻逼的不知道多用几组测试数据就是最后10分钟 随便试了一组测试数据;10 22 4 7 9 12 14 16 17 21 23一看就知道自己错在哪里了;就是后面求 t 的前面部分,吧判断条件写错了,他跟 t' 后面部分是不一样的,t后面大于 ,而t前面应该是小原创 2017-06-29 18:01:27 · 343 阅读 · 0 评论 -
URAL - 1889 E - Airport Announcements (好好读题!!!)
E - Airport AnnouncementsIgor was bored of waiting in an airport lounge. Oceanic Airlines, a company he didn't like so much, delayed the departure of his flight, so he was late for the con原创 2017-05-21 21:14:51 · 346 阅读 · 0 评论 -
2016_4_16/G [codeforces] C - Pythagorean Triples 数学 (直角三角形的边)
已知直角三角形一条边,求另外两条边;长见识了 原来有一种情况的直角三角形的 两条直角边是只差1或者2的;引用一下他们的博客:对于直角三角形△ABC,如图:我们知道的是因为题目说如果题目存在多种解,输出任何一个就可以了,所以我们不妨假设输入的n是一条直角边的长度,那么根据平方差公式可得原创 2017-04-17 19:59:11 · 296 阅读 · 0 评论 -
G/A - 食物链 POJ - 1182(并查集)
43.注意scanf,不然又会超时动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类。 第二种说法是"2 X Y",表示X吃Y。原创 2017-03-27 00:18:11 · 232 阅读 · 0 评论 -
组队赛(B/H Sudoku) HDU - 5547 (dfs)
一个数读题目;每次遇到一个“*”我们就枚举他变成1,2,3,4然后判断是否合法,如果合法就进行下一个点,否则回溯。还是很简单的思路,但是自己做的时候还是没有想到,对于dfs还是不够敏感#include #includeusing namespace std;const int maxn=105;char tu[6][6];int vis[6][6];int原创 2017-04-08 11:48:16 · 304 阅读 · 0 评论 -
2017.3.13 E - Largest Rectangle in a Histogram
又是一个time limitated很强E - Largest Rectangle in a HistogramA histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths原创 2017-03-13 08:12:09 · 184 阅读 · 0 评论 -
2017.3.13 E - Largest Rectangle in a Histogram
对于原来只是单纯地循环所以超时;A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rectangles have equal widths but may have different heights. For example, t原创 2017-03-13 00:02:25 · 159 阅读 · 0 评论 -
H/ G - Conscription POJ - 3723(最小生成树,并查集)
Windy has a country, and he wants to build an army to protect his country. He has picked upN girls and M boys and wants to collect them to be his soldiers. To collect a soldier without any privilege原创 2017-03-29 00:12:13 · 254 阅读 · 0 评论 -
(组队赛A/C)Gym - 101142C (搜索)
题意:给定n个人在两个网站上的得分,一个人若能在任意一个网站里战胜另一个人,则认为这个人能战胜那个人。问每个人都能战胜多少人。分析:1、战胜具有传递性。例如:4 52 73 3因为第三个人能战胜第二个人,第二个人能战胜第一个人,所以虽然第三个人两个分数都比第一个人低,但第三个人能战胜第一个人。2、按照某个网站的分数排好序,从分数最小的人dfs,经过的人全都标记下来,原创 2017-04-06 22:07:01 · 380 阅读 · 0 评论 -
5-f F - Semi-prime H-numbers
此题先打表错因,重复了#include #includeusing namespace std;const int maxn=1000010;int h[maxn];int primeh[maxn];int main(){ int n; for(int i=0,j=0;j<=maxn;i++) { j=4*i+1;原创 2017-03-11 20:38:18 · 164 阅读 · 0 评论 -
E/ G - Meteor Shower 爆爆爆逃离炸区 bfs
Bessie hears that an extraordinary meteor shower is coming; reports say that these meteors will crash into earth and destroy anything they hit. Anxious for her safety, she vows to find her way to a sa原创 2017-03-14 20:45:45 · 327 阅读 · 0 评论 -
2016.3.20 H/E - Backward Digit Sums( next_permutation写全排列)
呀吧。这个题居然是这样子的,自己补得,笑哭,就是一个全排列,因为数据太小所以不会超时全排列加上递归求树的和, next_permutation用来求全排列十分方便FJ and his cows enjoy playing a mental game. They write down the numbers from 1 to N (1 <= N <= 10) in a ce原创 2017-03-20 16:41:33 · 191 阅读 · 0 评论 -
二分法l例 E - Monthly Expenses1
E - Monthly Expensearmer John is an astounding accounting wizard and has realized he might run out of money to run the farm. He has already calculated and recorded the exact amount of money (1 ≤mo原创 2017-03-13 18:24:41 · 258 阅读 · 0 评论 -
二分法二 F - Dropping tests
F - Dropping testsIn a certain course, you taken tests. If you get ai out of bi questions correct on testi, your cumulative average is defined to be.Given your test scores and a positive原创 2017-03-13 19:10:46 · 144 阅读 · 0 评论 -
E/C - Sliding Window POJ - 2823 (单调数列;cout与 printf )
用了一个单调队列,还有注意printfAn array of size n ≤ 10 6 is given to you. There is a sliding window of size kwhich is moving from the very left of the array to the very right. You can only see the k num原创 2017-03-16 22:06:40 · 214 阅读 · 0 评论 -
D/ D - Expedition POJ - 2431(优先队列)
52坑爹了。。。注意优先队列的用法,默认是降序,由大到小排列的,(宛如一个智障,忘记了这一点,还用了priority_queueint ,vectorint>,greaterint> >a;)还有这个题处理数据后要进行排序,根据距离的远近这个题的思路转化为,在每到达一个地方就获得了以后可以加油的机会,#include #include#include#in原创 2017-03-26 10:29:08 · 261 阅读 · 0 评论 -
poj 1458Common Subsequence (dp)
Common SubsequenceTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 50877 Accepted: 20958DescriptionA subsequence of a given sequence is the given sequenc原创 2017-03-20 19:59:22 · 207 阅读 · 0 评论 -
H/D - Dollar Dayz (dp和大数)
做了一个并不对没想到会是用到大数,而且下面的代码是错误的#include #define LIMIT_ULL 100000000000000000using namespace std;const int maxi=1005;const int maxj=105;long long dp[maxi][maxi][2];long long w[maxi];int n,k原创 2017-03-21 20:02:57 · 275 阅读 · 0 评论 -
C/-d D - Saruman's Army
呀吧 可算是a掉了补得题,可算是懂得题目是啥意思了,就是最少包含范围,在给定的数左右 r的范围内都是可以的覆盖的,#include #includeusing namespace std;int army[1005];int main(){ int r,n; while(cin>>r>>n&&(r!=-1&&n!=-1)) { int nu原创 2017-03-11 23:54:14 · 268 阅读 · 0 评论 -
c/ C - Sumsets
用递归写的,然后超时了,知道应该去找规律,可是。。。。没找到尴尬递归的码#include using namespace std;int dou[25];int num;void findd(int n,int i){ int y=n/dou[i]; if(dou[i]>n) return ; for(int j=y;j>=原创 2017-03-12 00:05:19 · 283 阅读 · 0 评论 -
组队赛(F/D) UVALive - 7426(dfs)
这个题题题目的一开始没有看懂,后来理解了,这个代码的意思,但也并不是很懂 ,就是列举各种情况,在代码的各个位置插入输出,分割之后,程序崩坏另一边就不用判断,然后把已经求过的存下来,因为只要代码长度一样所花的时间是一样的看, 然后开始dfs返回搜索各种情况这个dfs略魔性,是为了储存值用的吧#include#include#include #include #defi原创 2017-04-10 16:48:57 · 330 阅读 · 0 评论