05 2017 档案

摘要:这题挺有意思的,刚开始不会这交互题,模仿着做了一题就会了,蛮简单 的 这题我用2分,结果wa了,想了一下发现,1到1e9二分50次完全不够用啊,那就转换一下思维,先求出在10^n~10^(n+1)的n 然后进行二分,这样居然a了。。。 #include<map> #include<set> #inc 阅读全文
posted @ 2017-05-26 18:03 walfy 阅读(349) 评论(0) 推荐(0)
摘要:反正又是一个半小时没做出来。。。 先排序,然后求和,第i个和第j个,f(a)=a[j]-a[i]=a[i]*(2^(j-i-1))因为从j到i之间有j-i-1个数(存在或者不存在有两种情况) 又有a[i+k]-a[i]=a[n]+a[n-1]+...+a[n-k]-a[k+1]-...-a[1] # 阅读全文
posted @ 2017-05-26 17:09 walfy 阅读(249) 评论(0) 推荐(0)
摘要:因为数组开小了,导致tle了一整天:( tle的几点原因:http://blog.csdn.net/ameir_yang/article/details/53698478 思路都是对的,把每个人进行拆点,和dining那题差不多,加一个超级源一个超级汇 #include<map> #include< 阅读全文
posted @ 2017-05-26 13:04 walfy 阅读(158) 评论(0) 推荐(0)
摘要:这题就是个模板题,不过我是第一次写dinic,好久没用链式前向星又不会了。。。 时间:9126ms #include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #includ 阅读全文
posted @ 2017-05-24 19:44 walfy 阅读(466) 评论(0) 推荐(0)
摘要:这题想了好久,一直认为应该bfs更新后求最小值把发电站最大发电加进去,但是又发现这样求增广路的时候会导致用户更新出错, 加源点和汇点也考虑到了,没想到居然发电量就是超级源到源点的v,居然这么简单@。@ #include<map> #include<set> #include<cmath> #incl 阅读全文
posted @ 2017-05-24 15:00 walfy 阅读(323) 评论(0) 推荐(0)
摘要:这题看了半天看不懂题意。。。还是看的网上题意写的 加一个源点一个汇点,把每个点拆成两个,这两个点的流量是v,其他联通的边都设为无穷大 输入没有1的点就与源点连接,输出只有1的点就与汇点连接 还有这个输出技巧,因为每条反向弧初始容量设置为0,因此完成增广之后,反向弧的容量即为路径。 #include< 阅读全文
posted @ 2017-05-22 18:20 walfy 阅读(639) 评论(0) 推荐(0)
摘要:加一个源点和汇点,把每头牛拆成两个点,不拆点的话可能会出现多对食物与饮料被一个牛享用的情况,拆点后流量为1,不能同时通过了 然后用最大流处理,每个链接边都是1 #include<map> #include<set> #include<cmath> #include<queue> #include<s 阅读全文
posted @ 2017-05-22 15:41 walfy 阅读(175) 评论(0) 推荐(0)
摘要:Ford-Fulkerson方法:dfs实现 dfs 140ms #include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #includ 阅读全文
posted @ 2017-05-21 15:57 walfy 阅读(212) 评论(0) 推荐(0)
摘要:挑战上面的题目,感觉脑洞很大 分别找红蓝个数全为偶,全为奇,一奇一偶的个数ai,bi,ci 转移矩阵是| 2 1 0 |,是一个对称矩阵(会不会有什么联系。) | 2 2 2 | | 0 1 2 | #include<map> #include<set> #include<cmath> #inclu 阅读全文
posted @ 2017-05-20 18:51 walfy 阅读(251) 评论(0) 推荐(0)
摘要:花了一个多小时终于ac了,有时候真的是需要冷静一下重新打一遍才行。 这题就是 |aod(n)| = |1 ax*bx ax*by ay*bx by*ay| |aod(n-1) | |an*bn | = |0 ax*bx ax*by ay*bx by*ay| |an-1*bn-1 | |an | = 阅读全文
posted @ 2017-05-20 18:27 walfy 阅读(156) 评论(0) 推荐(0)
摘要:转移矩阵很容易求就是|0 1|,第一项是|0| |1 1| |1| 然后直接矩阵快速幂,要用到费马小定理 :假如p是质数,且gcd(a,p)=1,那么 a(p-1)≡1(mod p)。即:假如a是整数,p是质数,且a,p互质(即两者只有一个公约数1),那么a的(p-1)次方除以p的余数恒等于1(这东 阅读全文
posted @ 2017-05-20 14:33 walfy 阅读(226) 评论(0) 推荐(0)
摘要:状态变化 (x,y,dx,dy,i) 表示i时刻熊站在(x,y)处速度向量(dx,dy)下一个状态是 ( 2x+y+dx+i , x+2y+dy+i , x+y+dx , x+y+dy , i+1 ) 为了方便可以把平面从(1,1)平移到(0,0) 这时速度需要+2 (因为速度每次+x+y x和y都 阅读全文
posted @ 2017-05-20 12:47 walfy 阅读(201) 评论(0) 推荐(0)
摘要:这题太坑了。。。刚开始以为可以用|a+sqrt(b) 1|水过。。。结果tle,还一直想明明我logn的做法怎么可能tle。。 | 0 1| 实在无奈看的题解 (a+sqrt(b))^n=x+y*sqrt(b); (a+sqrt(b))^(n+1)=a*x+b*y+(x+a*y)*sqrt(b) 这 阅读全文
posted @ 2017-05-18 13:48 walfy 阅读(138) 评论(0) 推荐(0)
摘要:a^(n+2)+b^(n+2)=(a+b)*(a^(n+1)+b^(n+1))-a*b*(a^n+b^n) 坑爹的题目关系式都推出来了居然还是wa了。。。。。 不能只看p,q=0就退出,因为a,b不一定为0啊,卧槽,出题人简直就是个心机婊 还有n=0的情况要考虑 #include<map> #inc 阅读全文
posted @ 2017-05-17 16:48 walfy 阅读(165) 评论(0) 推荐(0)
摘要:求A+A^1+...+A^n 转换一下变成|A E|,的n+1次方就是|A^(n+1) A^n+...+A+E| |0 E| | 0 E | 最后结果减去E就行了,还有一点就是-1之后可能会变成负数,所以要+10再%10 #include<map> #include<set> #include<cm 阅读全文
posted @ 2017-05-17 14:38 walfy 阅读(207) 评论(0) 推荐(0)
摘要:题目看了半天没看懂,,就是把一个数列更新r次,每次更新就是计算和,就是每一个数,只要出现了的表号都要加上去,具体看代码 矩阵快速幂实现加速 #include<map> #include<set> #include<cmath> #include<queue> #include<stack> #inc 阅读全文
posted @ 2017-05-17 13:01 walfy 阅读(176) 评论(0) 推荐(0)
摘要:#include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<vector> #include<cstdio> #include<iomanip> #include<cstdlib> #inc 阅读全文
posted @ 2017-05-17 10:38 walfy 阅读(220) 评论(0) 推荐(0)
摘要:这题不能直接按常规做啊,因为数组根本就开不下,转换思维A(B*A)^(n*n-1)B 这样的话数组B*A就是10*10了,然后快速幂就行了 刚开始数组都开小了,tle,还找了半天bug。。。还有就是定义三个struct真累。。。 #include<map> #include<set> #includ 阅读全文
posted @ 2017-05-16 20:35 walfy 阅读(159) 评论(0) 推荐(0)
摘要:就是优化一段代码,用矩阵快速幂(刚开始想到了转移矩阵以为是错的) 在搜题解时发现了一个神奇的网站:http://oeis.org/ 用来找数列规律 的神器。。。。 规律就是an=an-1+2*an-2+1 然后构造矩阵就行了 还有特例1的时候记得%m #include<map> #include<s 阅读全文
posted @ 2017-05-16 19:25 walfy 阅读(187) 评论(0) 推荐(0)
摘要:参考博客:http://blog.csdn.net/rowanhaoa/article/details/39343769 反正递推关系式推了一个多小时没搞出来。。。太弱了 真是愧对数学系这一专业了。。。。 转移矩阵就是这个: 10 0 0 0 0 1 10 1 0 0 0 1 10 1 1 0 0 阅读全文
posted @ 2017-05-15 21:25 walfy 阅读(232) 评论(0) 推荐(0)
摘要:找出递推关系式就好了 (fi+1)=(1 -1)(fi ) ( fi)=(1 0)(fi-1) 不会打矩阵将就着看吧。。。 这是第一道矩阵快速幂。细节还是有很多没注意到的 本来想看挑战写的,结果上面的vector套vector看的我头都晕了。。 #include<map> #include<set> 阅读全文
posted @ 2017-05-15 19:54 walfy 阅读(189) 评论(0) 推荐(0)
摘要:During several decades, scientists from planet Nibiru are working to create an engine that would allow spacecrafts to fall into hyperspace and move th 阅读全文
posted @ 2017-05-15 16:48 walfy 阅读(198) 评论(0) 推荐(0)
摘要:题意:给一个图,1是可以放,0是不能放,可以放的地方放的不能相邻,求所有情况 题解:状压dp 参考博客:http://www.tuicool.com/articles/JVzMVj #include<map> #include<set> #include<cmath> #include<queue> 阅读全文
posted @ 2017-05-13 16:01 walfy 阅读(137) 评论(0) 推荐(0)
摘要:状压dp第一题:很多东西没看懂,慢慢来,状压dp主要运用了位运算,二进制处理 集合{0,1,2,3,....,n-1}的子集可以用下面的方法编码成整数 像这样,一些集合运算就可以用如下的方法来操作: 1.空集....................0 2.只含有第i个元素的集合{i}........ 阅读全文
posted @ 2017-05-12 14:19 walfy 阅读(200) 评论(0) 推荐(0)
摘要:It's time for music! A lot of popular musicians are invited to join us in the music festival. Each of them will play one of their representative songs 阅读全文
posted @ 2017-05-11 22:16 walfy 阅读(171) 评论(0) 推荐(0)
摘要:Chen, Adrian (November 7, 2013). “Doge Is An Ac- tually Good Internet Meme. Wow.”. Gawker. Retrieved November 22, 2013. Doge is an Internet meme that 阅读全文
posted @ 2017-05-10 15:13 walfy 阅读(215) 评论(0) 推荐(0)
摘要:One day, sailormoon girls are so delighted that they intend to research about palindromic strings. Operation contains two steps: First step: girls wil 阅读全文
posted @ 2017-05-10 14:47 walfy 阅读(246) 评论(0) 推荐(0)
摘要:吉哥又想出了一个新的完美队形游戏! 假设有n个人按顺序站在他的面前,他们的身高分别是h11, h22 ... hnn,吉哥希望从中挑出一些人,让这些人形成一个新的队形,新的队形若满足以下三点要求,则就是新的完美队形: 1、挑出的人保持原队形的相对顺序不变,且必须都是在原队形中连续的; 2、左右对称, 阅读全文
posted @ 2017-05-10 13:38 walfy 阅读(119) 评论(0) 推荐(0)
摘要:Andy the smart computer science student was attending an algorithms class when the professor asked the students a simple question, "Can you propose an 阅读全文
posted @ 2017-05-10 13:02 walfy 阅读(159) 评论(0) 推荐(0)
摘要:给出一个只由小写英文字符a,b,c...y,z组成的字符串S,求S中最长回文串的长度. 回文就是正反读都是一样的字符串,如aba, abba等 Input输入有多组case,不超过120组,每组输入为一行小写英文字符a,b,c...y,z组成的字符串S 两组case之间由空行隔开(该空行不用处理)  阅读全文
posted @ 2017-05-10 13:01 walfy 阅读(208) 评论(0) 推荐(0)
摘要:For each prefix with length P of a given string S,if S[i]=S[i+P] for i in [0..SIZE(S)-p-1], then the prefix is a “period” of S. We want to all the per 阅读全文
posted @ 2017-05-08 20:33 walfy 阅读(264) 评论(0) 推荐(0)
摘要:Give you n ( n < 10000) necklaces ,the length of necklace will not large than 100,tell me How many kinds of necklaces total have.(if two necklaces can 阅读全文
posted @ 2017-05-08 19:07 walfy 阅读(521) 评论(0) 推荐(0)
摘要:Give you a string with length N, you can generate N strings by left shifts. For example let consider the string “SKYLONG”, we can generate seven strin 阅读全文
posted @ 2017-05-08 17:07 walfy 阅读(153) 评论(0) 推荐(0)
摘要:Beside other services, ACM helps companies to clearly state their “corporate identity”, which includes company logo but also other signs, like tradema 阅读全文
posted @ 2017-05-08 14:42 walfy 阅读(118) 评论(0) 推荐(0)
摘要:You are given a number of case-sensitive strings of alphabetic characters, find the largest string X, such that either X, or its inverse can be found 阅读全文
posted @ 2017-05-08 14:41 walfy 阅读(455) 评论(0) 推荐(0)
摘要:It is well known that AekdyCoin is good at string problems as well as number theory problems. When given a string s, we can write down all the non-emp 阅读全文
posted @ 2017-05-06 22:39 walfy 阅读(580) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2017-05-06 21:35 walfy 阅读(121) 评论(0) 推荐(0)
摘要:The Genographic Project is a research partnership between IBM and The National Geographic Society that is analyzing DNA from hundreds of thousands of 阅读全文
posted @ 2017-05-06 20:58 walfy 阅读(2136) 评论(2) 推荐(0)
摘要:The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat to give names to their newly-born babies 阅读全文
posted @ 2017-05-05 13:39 walfy 阅读(259) 评论(0) 推荐(0)
摘要:Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concate 阅读全文
posted @ 2017-05-04 20:37 walfy 阅读(95) 评论(0) 推荐(0)
摘要:There is a string A. The length of A is less than 1,000,000. I rewrite it again and again. Then I got a new string: AAAAAA...... Now I cut it from two 阅读全文
posted @ 2017-05-04 19:51 walfy 阅读(130) 评论(0) 推荐(0)
摘要: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 pr 阅读全文
posted @ 2017-05-04 19:40 walfy 阅读(131) 评论(0) 推荐(0)
摘要: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 le 阅读全文
posted @ 2017-05-04 18:47 walfy 阅读(126) 评论(0) 推荐(0)
摘要: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 fr 阅读全文
posted @ 2017-05-04 16:35 walfy 阅读(191) 评论(0) 推荐(0)
摘要:一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案。对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢? Input输入中含有一些数据,分别是成对出现的花布条和小饰条,其布条都是用可见ASCII字符表示的,可见的ASCII字符有多少个,布条的花纹也有多少种花样。 阅读全文
posted @ 2017-05-04 15:18 walfy 阅读(219) 评论(0) 推荐(0)
摘要:Given two sequences of numbers : a11, a22, ...... , aNN, and b11, b22, ...... , bMM (1 <= M <= 10000, 1 <= N <= 1000000). Your task is to find a numbe 阅读全文
posted @ 2017-05-04 15:15 walfy 阅读(378) 评论(0) 推荐(0)
摘要:Japan plans to welcome the ACM ICPC World Finals and a lot of roads must be built for the venue. Japan is tall island with N cities on the East coast 阅读全文
posted @ 2017-05-03 14:29 walfy 阅读(174) 评论(0) 推荐(0)
摘要:Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows. The area is divided into squares. The squares fo 阅读全文
posted @ 2017-05-03 11:47 walfy 阅读(170) 评论(0) 推荐(0)
摘要:Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th column. Initially we have A[i, j] = 0 (1 <= 阅读全文
posted @ 2017-05-03 11:16 walfy 阅读(159) 评论(0) 推荐(0)