自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

哇哈哈哈的博客

努力不一定会赢,但不努力是肯定不会赢的

  • 博客(274)
  • 收藏
  • 关注

原创 银河英雄传说(边带权并查集)

题目:有一个划分为N列的星际战场,各列依次编号为1,2,…,N。有N艘战舰,也依次编号为1,2,…,N,其中第i号战舰处于第i列。有T条指令,每条指令格式为以下两种之一:1、M i j,表示让第i号战舰所在列的全部战舰保持原有顺序,接在第j号战舰所在列的尾部。2、C i j,表示询问第i号战舰与第j号战舰当前是否处于同一列中,如果在同一列中,它们之间间隔了多少艘战舰。...

2019-08-09 15:41:00 153

原创 程序自动分析(并查集+离散化)

题目:在实现程序自动分析的过程中,常常需要判定一些约束条件是否能被同时满足。考虑一个约束满足问题的简化版本:假设x1,x2,x3,…代表程序中出现的变量,给定n个形如xi=xjxi=xj或xi≠xjxi≠xj的变量相等/不等的约束条件,请判定是否可以分别为每一个变量赋予恰当的值,使得上述所有约束条件同时被满足。例如,一个问题中的约束条件为:x1=x2,x2=x...

2019-08-09 14:11:00 150

原创 关于树状数组的小总结(树状数组)

该博客借鉴大佬博客理论内容:https://www.cnblogs.com/xenny/p/9739600.html1.什么是树状数组?顾名思义,就是用数组来模拟树形结构呗。那么衍生出一个问题,为什么不直接建树?答案是没必要,因为树状数组能处理的问题就没必要建树。和Trie树的构造方式有类似之处。2.树状数组可以解决什么问题可以解决大部分基于区间上的更新以及求和问题。...

2019-08-09 11:33:00 177

原创 你能回答这些问题吗 (线段树)

题目:给定长度为N的数列A,以及M条指令,每条指令可能是以下两种之一:1、“1 x y”,查询区间 [x,y] 中的最大连续子段和,即2、“2 x y”,把 A[x] 改成 y。对于每个查询指令,输出一个整数表示答案。输入格式第一行两个整数N,M。第二行N个整数A[i]。接下来M行每行3个整数k,x,y,k=1表示查询(此时如果x>y,请交换...

2019-08-08 18:29:00 278

原创 Devu和鲜花 (容斥原理)

题目:Devu有N个盒子,第i个盒子中有Ai枝花。同一个盒子内的花颜色相同,不同盒子内的花颜色不同。Devu要从这些盒子中选出M枝花组成一束,求共有多少种方案。若两束花每种颜色的花的数量都相同,则认为这两束花是相同的方案。结果需对109+7取模之后方可输出。输入格式第一行包含两个整数N和M。第二行包含N个空格隔开的整数,表示A1,A2,…,AN。输出格...

2019-08-06 17:26:00 329

转载 【高斯消元讲解+模板】(数论)

转自某位奆佬的总结:链接:https://blog.csdn.net/Septembre_/article/details/81221027大佬讲解:https://blog.csdn.net/pengwill97/article/details/77200372大佬模板:https://blog.csdn.net/pengwill97/article/details/772...

2019-08-04 22:12:40 147

原创 【表达整数的奇怪方式】(中国剩余定理(非互素))

题目:给定2n个整数a1,a2,…,ana1,a2,…,an和m1,m2,…,mnm1,m2,…,mn,求一个最小的非负整数x,满足∀i∈[1,n],x≡mi(modai)∀i∈[1,n],x≡mi(modai)。输入格式第1行包含整数n。第2..n行:每i+1行包含两个整数aiai和mimi,数之间用空格隔开。输出格式输出最小非负整数x,如果x不存在,则输出-1。如...

2019-08-04 15:08:07 389

原创 【最幸运的数字】(欧拉降幂)

题目:8是中国的幸运数字,如果一个数字的每一位都由8构成则该数字被称作是幸运数字。现在给定一个正整数L,请问至少多少个8连在一起组成的正整数(即最小幸运数字)是L的倍数。输入格式输入包含多组测试用例。每组测试用例占一行,包含一个整数L。当输入用例L=0时,表示输入终止,该用例无需处理。输出格式每组测试用例输出结果占一行。结果为“Case 1: ”+一个整数N,N...

2019-08-04 14:05:07 449

原创 【欧拉函数】(数论)

何为欧拉函数:在1-N中与N互质的数的个数被称为欧拉函数,记为φ(N).若在算术基本定理中,N=p1^c1*p2^c2*....pm^cm,则φ(N)=N*(p1-1)/p1*(p2-1)/p2*****(pm-1)/pm=N*ㄇ质数p|N (1-1/p)模板:求解单个数的欧拉函数计算式:ll eluer(ll n){ ll ans=n; for(ll i=2...

2019-08-04 13:24:16 1762

原创 【余数之和】 (数学,分块)

题目:给出正整数n和k,计算j(n, k)=k mod 1 + k mod 2 + k mod 3 + … + k mod n的值。例如j(5, 3)=3 mod 1 + 3 mod 2 + 3 mod 3 + 3 mod 4 + 3 mod 5=0+1+0+3+3=7。输入格式输入仅一行,包含两个整数n, k。输出格式输出仅一行,即j(n, k)。数据范围1≤n,...

2019-08-02 15:15:45 495

原创 反素数的学习及题目【反素数】

何为反素数:对于任何正整数x,其约数的个数记作g(x),例如g(1)=1、g(6)=4。如果某个正整数x满足:对于任意的小于x的正整数 i,都有g(x)>g(i) ,则称x为反素数。例如,整数1,2,4,6等都是反素数。反素数的三条性质:一:1~N中的最大的反素数,就是1~N中约数个数最多的数中的最小的一个证明:设m是1~N中约数数目最多的数中的最小的一个,根据m的定...

2019-08-02 13:50:37 1446

原创 【 阶乘分解】(素数)

题目:给定整数 N ,试把阶乘 N! 分解质因数,按照算术基本定理的形式输出分解结果中的pipi和cici即可。输入格式一个整数N。输出格式N! 分解质因数后的结果,共若干行,每行一对pi,cipi,ci,表示含有pciipici项。按照pipi从小到大的顺序输出。数据范围1≤N≤1061≤N≤106输入样例:5输出样例:2 33 15...

2019-08-02 09:51:21 1701

原创 质数距离【素数筛】

题目:给定两个整数L和U,你需要在闭区间[L,U]内找到距离最接近的两个相邻质数C1和C2(即C2-C1是最小的),如果存在相同距离的其他相邻质数对,则输出第一对。同时,你还需要找到距离最远的两个相邻质数D1和D2(即D1-D2是最大的),如果存在相同距离的其他相邻质数对,则输出第一对。输入格式每行输入两个整数L和U,其中L和U的差值不会超过1000000。输出格式对于每个...

2019-08-01 21:22:39 525

原创 最佳牛围栏【二分】

题目:农夫约翰的农场由NN块田地组成,每块地里都有一定数量的牛,其数量不会少于1头,也不会超过2000头。约翰希望用围栏将一部分连续的田地围起来,并使得围起来的区域内每块地包含的牛的数量的平均值达到最大。围起区域内至少需要包含FF块地,其中FF会在输入中给出。在给定条件下,计算围起区域内每块地包含的牛的数量的平均值可能的最大值是多少。输入格式第一行输入整数N和...

2019-08-01 11:21:10 604

原创 最高的牛【一维差分】

题目:有NN头牛站成一行,被编队为1、2、3…N,每头牛的身高都为整数。当且仅当两头牛中间的牛身高都比它们矮时,两头牛方可看到对方。现在,我们只知道其中最高的牛是第PP头,它的身高是HH,剩余牛的身高未知。但是,我们还知道这群牛之中存在着MM对关系,每对关系都指明了某两头牛AA和BB可以相互看见。求每头牛的身高的最大可能值是多少。输入格式第一行输...

2019-07-31 20:57:17 426

原创 约数之和【质因数分解+等比数列求和】

题目:假设现在有两个自然数A和B,S是ABAB的所有约数之和。请你求出S mod 9901的值是多少。输入格式在一行中输入用空格隔开的两个整数A和B。输出格式输出一个整数,代表S mod 9901的值。数据范围0≤A,B≤5×1070≤A,B≤5×107输入样例:2 3输出样例:15注意: A和B不会同时为0。解题报告:由于A,...

2019-07-30 20:14:54 343

原创 最短Hamilton路径(哈密顿图,状压dp)

题目:给定一张n个点的带权无向图,点从 0~n-1 标号,求起点 0 到终点 n-1 的最短Hamilton路径。 Hamilton路径的定义是从 0 到 n-1 不重不漏地经过每个点恰好一次。输入格式第一行输入整数n。接下来n行每行n个整数,其中第ii行第jj个整数表示点ii到jj的距离(记为a[i,j])。对于任意的x,y,z,数据保证 a[x,x]=0,a[x,...

2019-07-30 15:42:38 4319 1

原创 【Fibonacci Tree】(最小生成树排序 2013icpc成都)

题目:  Coach Pang is interested in Fibonacci numbers while Uncle Yang wants him to do some research on Spanning Tree. So Coach Pang decides to solve the following problem:  Consider a bidirectional ...

2019-07-01 22:18:29 299

原创 【Hard Disk Drive 】(简单题 2013icpc成都)

题目:Yesterday your dear cousin Coach Pang gave you a new 100MB hard disk drive (HDD) as a gift because you will get married next year.  But you turned on your computer and the operating system (OS)...

2019-07-01 22:10:03 589

原创 【A + B Problem II 】【HDU - 1002 】(高精度加法)

题目:I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.InputThe first line of the input contains an integer T(1<=T<=20) which means...

2019-06-12 17:10:05 350

原创 【Matrix Game】(nim博弈)

题目:Given anm x nmatrix, wheremdenotes the number of rows andndenotes the number of columns and in each cell a pile of stones is given. For example, let there be a2 x 3matrix, and the piles a...

2019-06-04 11:22:26 1149

原创 【Proud Merchants 】(需要排序的01背包)

题目:Recently, iSea went to an ancient country. For such a long time, it was the most wealthy and powerful kingdom in the world. As a result, the people in this country are still very proud even if th...

2019-06-03 21:51:12 269

原创 【Bag of mice】【CodeForces 148D】 (概率dp)

题目:The dragon and the princess are arguing about what to do on the New Year's Eve. The dragon suggests flying to the mountains to watch fairies dancing in the moonlight, while the princess thinks th...

2019-02-08 14:50:45 225

原创 【MUH and House of Cards】【CodeForces - 471C】(数学+思维)

题目:Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playin...

2019-01-20 22:27:21 503

原创 【Strongly Connected City】【CodeForces - 475B】(floyd)

题目:Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street o...

2019-01-20 21:10:33 229

原创 【Design Tutorial: Learn from Life】【CodeForces - 472B】(思维)

题目:One way to create a task is to learn from life. You can choose some experience in real life, formalize it and then you will get a new task.Let's think about a scene in real life: there are lots...

2019-01-20 18:39:12 221

原创 【Data Structure? 】【HDU - 4217】(线段树入门)

题目:Data structure is one of the basic skills for Computer Science students, which is a particular way of storing and organizing data in a computer so that it can be used efficiently. Today let me in...

2018-12-22 23:35:48 188

原创 【Number Theory?】【HDU - 4215】(思维+打表)

题目:In number theory, for a positive number N, two properties are often mentioned, one is Euler's function, short for E(N), another is factor number, short for F(N). To be more precise for newbie, h...

2018-12-22 23:24:45 467

原创 【Anton and currency you all know】【CodeForces - 508B 】(思维)

题目:Berland, 2016. The exchange rate of currency you all know against the burle has increased so much that to simplify the calculations, its fractional part was neglected and the exchange rate is now...

2018-12-21 22:17:05 193

原创 【Amr and Pins】【CodeForces - 507B 】(思维+贪心)

题目:Amr loves Geometry. One day he came up with a very interesting problem.Amr has a circle of radius r and center in point (x, y). He wants the circle center to be in new position (x', y').In on...

2018-12-21 22:08:53 241

原创 【A Simple Math Problem】【HDU - 1757 】(矩阵快速幂)

题目:Lele now is thinking about a simple function f(x). If x &lt; 10 f(x) = x. If x &gt;= 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10); And ai(0&lt;=i&lt;=9) can only be 0 ...

2018-12-20 22:35:01 229

原创 【Disturbed People】【CodeForces - 1077B】(思维水题)

题目:There is a house with nn flats situated on the main street of Berlatov. Vova is watching this house every night. The house can be represented as an array of nninteger numbers a1,a2,…,ana1,a2,…,an...

2018-12-20 22:28:36 449

原创 【Roadblocks】【POJ - 3255】(次短路)(模板裸题)

题目:Bessie has moved to a small farm and sometimes enjoys returning to visit one of her best friends. She does not want to get to her old home too quickly, because she likes the scenery along the way...

2018-12-20 22:15:44 310

原创 【The Moving Points】【HDU - 4717】(三分plus)

题目:There are N points in total. Every point moves in certain direction and certain speed. We want to know at what time that the largest distance between any two points would be minimum. And also, we...

2018-12-20 21:01:47 286

原创 【Planets】【CodeForces - 230D】(spfa+二分)

题目:Goa'uld Apophis captured Jack O'Neill's team again! Jack himself was able to escape, but by that time Apophis's ship had already jumped to hyperspace. But Jack knows on what planet will Apophis l...

2018-12-18 16:51:25 1188

原创 【Anniversary party】【HDU - 1520】(树形dp)

题目:There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees. It means that the supervisor relation forms...

2018-12-11 16:39:38 159

原创 【Watering Grass】【UVA - 10382】(区间覆盖)

题目:    n sprinklers are installed in a horizontal strip of grass l meters long and w meters wide. Each sprinkler is installed at the horizontal center line of the strip. For each sprinkler we are gi...

2018-12-06 20:02:02 193

原创 【Dragon of Loowater】【UVA - 11292】(思维)

题目:    Once upon a time, in the Kingdom of Loowater, a mi- nor nuisance turned into a major problem.    The shores of Rellau Creek in central Loowater had always been a prime breeding ground for g...

2018-12-06 19:54:17 150

原创 【Beijing Guards】【UVA - 1335】(思维)

题目:    Beijing was once surrounded by four rings of city walls: the Forbidden City Wall, the Imperial City Wall, the Inner City Wall, and finally the Outer City Wall. Most of these walls were demoli...

2018-12-06 19:42:26 208

原创 【Bridge】【UVA - 10037】(思维)

题目:n people wish to cross a bridge at night. A group of at most two people may cross at any time, and each group must have a flashlight. Only one flashlight is available among the n people, so some ...

2018-12-06 14:59:17 315

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除