自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(39)
  • 收藏
  • 关注

原创 HDU 5531 Rebuild(几何)

RebuildTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 2660    Accepted Submission(s): 584Problem DescriptionArchaeologists find

2017-09-29 16:28:55 286

原创 数论总结1

数论总结1欧几里德欧几里德算法又称辗转相除法,用于计算两个整数a,b的最大公约数。ll gcd(ll a,ll b){ return b?gcd(b,a%b):a;}扩展欧几里德ll exgcd(ll a,ll b,ll&x,ll&y){ if(b==0){ x=1; y=0; return a; } ll r=...

2017-09-13 21:37:44 256

原创 ZOJ 3956 Course Selection System(01背包变形)

Course Selection SystemTime Limit: 1 Second      Memory Limit: 65536 KB There are n courses in the course selection system of Marjar University. Thei-th course is described by two values:

2017-09-04 21:20:21 279

原创 HDU 2639 Bone Collector II(01背包第K大解)

Bone Collector IITime Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5127    Accepted Submission(s): 2706Problem DescriptionThe title

2017-09-03 22:06:36 215

原创 01背包问题*3

HDU2546 饭卡Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 22098    Accepted Submission(s): 7730Problem Description电子科大本部食堂的饭

2017-09-02 20:11:16 298

原创 动态规划-最大子段和系列问题

1.最大子段和给出一个长度为n的序列A1, A2,…, An,求最大连续和。即要求找到1≤i≤j≤n,使得Ai+Ai+1+…Aj尽量大,若结果小于0,则输出0。#include#include#includeusing namespace std;int main(){ int N,ipt,prem,sum,ans; scanf("%d",&N); su

2017-08-20 19:12:02 472

原创 UVA 1025 A Spy in the Metro(dp)

【题目链接】UVA-1025【题意】       某城市的地铁是线性的,有n(2≤n≤50)个车站,从左到右编号为1~n。有M1辆列车从第1站开始往右开,还有M2辆列车从第n站开始往左开。在时刻0,Mario从第1站出发,目的是在时刻T(0≤T≤200)会见车站n的一个间谍。在车站等车时容易被抓,所以她决定尽量躲在开动的火车上,让在车站等待的总时间尽量短。列车靠站停车时间忽略不计,且M

2017-08-18 20:14:27 202

原创 NYOJ 16 矩形嵌套(DAG上的动态规划)

【题目链接】NYOJ16-矩形嵌套【题意】有n个矩形,每个矩形可以用a,b来描述,表示长和宽。矩形X(a,b)可以嵌套在矩形Y(c,d)中当且仅当a【样例】样例输入1101 22 45 86 107 93 15 812 109 72 2样例输出5【分析】       矩形之间的“可嵌套”关系是一个典型的二元关系,二元关系可以用图来建模。如果矩形X可以嵌套在矩形Y里,就从

2017-08-18 14:16:01 534

原创 HDU 6127 Hard challenge(几何)

【题目链接】hdu-6127【题意】平面直角坐标系上有n个整点,第i个点有一个点权v​​,坐标为(xi,yi),其中不存在任意两点连成的直线经过原点。这些整点两两之间连有一条线段,线段的权值为其两端点的权值之积。你需要作一条过原点而不过任意一个给定整点的直线,使得和这条直线相交的线段的权值和最大。【样例】Sample Input221 1 11 -1 131 1

2017-08-16 16:58:56 253

原创 2017百度之星初赛(A) 1001 小C的倍数问题(余数定理)

【题目链接】HDU-6108【题意】        给定进制P,求有多少个B满足P进制下,一个正整数是B的倍数的充分必要条件是每一位加起来的和是B的倍数。 【分析】       假设有一个数s,按位记为abcd,在p进制下,可以转换为 s = a*p^3+b*p^2+c*p^1+d,分离出a+b+c+d,得s = a*(p^3-1)+b*(p^2-1)+c*(p^1-1)+a+

2017-08-13 00:49:30 338

原创 HDU 6097 Mindis(反演)

【题目链接】hdu 6097【题意】有一个圆心在原点的圆,给定圆的半径,给定P、Q两点坐标(PO=QO,P、Q不在圆外),取圆上一点D,求PD+QD的最小值。【样例】Sample Input444 00 440 33 040 22 040 11 0 Sample Output5.65685435.65685435.894503

2017-08-11 17:15:02 1185 2

原创 UVA 11212 Editing a Book(IDA*)

【题目链接】UVA-11212【题意】给一串长度为n的数字序列(n【样例】Sample Input62 4 1 5 3 653 4 5 1 2 0Sample OutputCase 1: 2 Case 2: 1【分析】       做的第一道IDA*。       当然应该考虑一下为什么不得不走向IDA*。       首先考虑单纯的dfs:

2017-08-07 23:04:03 302

原创 UVA 10603 Fill(状态空间搜索,倒水问题)

【题目链接】uva-10603【题意】设3个杯子的容量分别为a, b, c,最初只有第3个杯子装 满了c升水,其他两个杯子为空。最少需要倒多少升水才能让某一个杯子中的水有d升呢?如果无法做到恰好d升,就让某一个杯子里的水是d'升,其中d'【样例】Sample Input22 3 4 296 97 199 62Sample Output2 29859 62【分

2017-08-04 14:36:44 700

原创 Codeforces Round #426 (Div. 2) C. The Meaningless Game

【题目链接】codeforces#【题意】两人玩游戏,初始都是1分,每一局之后,赢的人*K^2,输的人*K,给出若干组比赛结果,问是否可能发生。【样例】Input62 475 458 816 16247 9941000000000 1000000OutputYesYesYesNoNoYes【分析】每一局都有一个人*K^2,

2017-07-31 16:12:27 202

原创 UVA 221 Urban Elevations(离散化)

【题目链接】UVA-221【题意】输入每个建筑物左下角坐标(即x、y坐标的最小值)、宽度(即x方向的长度)、深度 (即y方向的长度)和高度(以上数据均为实数),输出正视图中能看到的所有建筑物,按 照左下角x坐标从小到大进行排序。左下角x坐标相同时,按y坐标从小到大排序。【样例】Sample Input14160 0 30 60 30125 0 32 28 60

2017-07-31 15:55:51 278

原创 UVA 548 Tree(中序+后序还原二叉树)

【题目链接】UVA 548【题意】已知二叉树的中序和后序遍历结果,求到根的路径上结点值之和最小的叶子结点的值。【样例】3 2 1 4 5 7 63 1 2 5 6 7 47 8 11 3 5 16 12 188 3 11 7 16 18 12 5255255【分析】重点是根据中序和后序还原二叉树。这里要利用递归的思想。手动模拟大家都会,写出来还是有点难的…我给每

2017-07-27 21:13:19 335

原创 UVA 122 Trees on the level(指针二叉树,层次遍历)

【题目链接】UVA-122【题意】按照(结点值,结点位置)给出一系列树上结点的信息,位置为空的表示是根结点,以()结束一组输入。要求输出以此方式建立的树的层次遍历结果。如果有其他结点经过但是未被赋值的结点、或者有结点被多次赋值,则输出not complete。【样例】Sample Input (11,LL) (7,LLL) (8,R) (5,) (4,L) (13,RL) (2,L

2017-07-26 16:21:06 379

原创 2017福建省赛Problem D Game(KMP)

【题目链接】FZU【题意】有A、B两个数,可以对数字进行倒置或除以10的操作,Alice可以操作A,Bob可以操作B,轮流操作,Alice先操作。如果最后AB相同就Alice获胜,否则Bob。【样例】【分析】就是判断字符串B是否包含在字符串A或A逆中。KMP模板题。需要特别判断一下B=0的情况。【代码】#include#include#include#includ

2017-07-24 17:25:07 225

原创 2017福建省赛Problem B Triangles(判断两三角形位置关系)

【题目链接】FZU【题意】给定两个三角形6个点的坐标,判断两个三角形是包含、相交还是相离。【样例】【分析】【代码】#include#include#includeusing namespace std;int ans;typedef struct{ double x,y;}Point;Point S[6];double area(Point a,Po

2017-07-24 17:15:30 362

原创 HDU 5536 Chip Factory(01字典树)

【题目链接】HDU 5536【题意】给定一组数字,求这组数字中两数之和与第三个数抑或的最大值。【样例】【分析】求某个数和一组数的最大抑或值可以用01字典树。这里就是在此基础上增加了一些操作。先将所有数字插入字典树,枚举两数之和,删去这两个数在字典树中的记录,然后插入两数之和与字典树中记录数字的最大抑或值,单次查询后,在将这两个删去的数插入字典树。取所有查询结果的最大值,即为所求。这

2017-07-24 17:05:19 202

原创 HDU 4825 Xor Sum(01字典树)

【题目链接】HDU 4825【题意】给一个集合,集合中包含了N个正整数,随后发起M次询问,每次询问中包含一个正整数 S,需要在集合当中找出一个正整数 K ,使得 K 与 S 的异或结果最大。【样例】【分析】要计算抑或值,需要将两个数转化为二进制然后依次比对每一位。要从一组数中选出与S抑或最大的数,就需要从最高位开始比较,每次都选择与S在该位上数字不同的那些数,就这样向下计算

2017-07-23 16:23:10 209

原创 UVA 12657 Boxes in a Line(双向链表)

【题目链接】UVA-12657 Boxes in a Line【样例】【题意】给定N个盒子,依次标号为1~N,有下面4种操作:1 X Y 表示将X移到Y的左边;2 X Y 表示将Y移到Y的右边;3 X Y 表示交换X与Y的位置;4  表示将1~N所有的盒子反序。要你求经过M次操作之后,所有奇数位置的盒子标号之和。【分析】首先考虑第4种操作:可

2017-07-21 22:29:57 218

原创 UVA 11988 Broken Keyboard (链表)

Broken Keyboard (a.k.a. Beiju Text)You’re typing a long text with a broken keyboard. Well it’s not so badly broken. The only problem with the keyboard is that sometimes the “home” key or the “end” k

2017-07-21 15:10:32 220

原创 UVA 156 Ananagrams(map、set)

Ananagrams        Most crossword puzzle fans are used to anagrams — groups of words with the same letters in different orders — for example OPTS, SPOT, STOP, POTS and POST. Some words however do not

2017-07-15 22:19:54 171

原创 UVA 10815 Andy's First Dictionary(stringstream,set等)

Andy's First DictionaryAndy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy task for him, as the number of words that he knows is, well, not quite enough. Instead

2017-07-15 19:21:37 239

原创 CodeForces 831C Jury Marks(set)

C. Jury Markstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp watched TV-show where k jury members one by on

2017-07-14 15:53:55 466

原创 POJ 3067 Japan(树状数组求逆序对个数)

POJ 3067 JapanJapan 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 and M cities on the West coast (M

2017-05-12 21:52:16 332

原创 ZOJ 3953 Intervals(区间贪心)

Chiaki has n intervals and the i-th of them is [li, ri]. She wants to delete some intervals so that there does not exist three intervals a, b and c such that a intersects with b, b intersects with c a

2017-05-11 21:50:37 264

原创 ZOJ 3946 Highway Project(最小费用最短路,优先队列优化dijkstra)

ZOJ 3946 Highway ProjectEdward, the emperor of the Marjar Empire, wants to build some bidirectional highways so that he can reach other cities from the capital as fast as possible. Thus, he propos

2017-04-19 22:23:13 305

原创 ZOJ 3780 Paint the Grid Again(拓扑排序)

ZOJ 3780 Paint the Grid AgainLeo has a grid with N × N cells. He wants to paint each cell with a specific color (either black or white).Leo has a magical brush which can paint any row with black

2017-04-17 23:47:03 321

原创 Color(树形dp)——2017 Wuhan University Programming Contest (Online Round)

2017 Wuhan University Programming Contest (Online Round)B.ColorInput file: standard inputOutput file: standard output Time limit: 1 secondMemory limit: 512 mebibytesWhen Asuho was just a

2017-04-15 22:20:17 321

原创 ZOJ 3872 Beauty of Array(DP)

ZOJ 3872 Beauty of ArrayEdward has an array A with N integers. He defines the beauty of an array as the summation of all distinct integers in the array. Now Edward wants to know the summation of the

2017-04-13 22:25:40 353

原创 HDU 4183 Pahom on Water(最大流,判断两点间无相同点的简单路径的条数)

HDU 4183 Pahom on WaterPahom on Water is an interactive computer game inspired by a short story of Leo Tolstoy about a poor man who, in his lust for land, forfeits everything. The game's starting sc

2017-04-01 23:28:20 333

原创 HDU 3338 Kakuro Extension(最大流,拆点)

HDU 3338 Kakuro ExtensionIf you solved problem like this, forget it.Because you need to use a completely different algorithm to solve the following one.Kakuro puzzle is played on a grid of "bl

2017-04-01 22:47:18 280

原创 HDU 3572 Task Schedule(最大流判满流,SAP)

HDU 3572 Task ScheduleOur geometry princess XMM has stoped her study in computational geometry to concentrate on her newly opened factory. Her factory has introduced M new machines in order to proce

2017-03-28 22:28:43 319

原创 POJ 3255 Roadblocks(次短路,Dijkstra变形+邻接表存储)

POJ 3255 RoadblocksBessie 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 scene

2017-03-24 20:50:51 647

原创 POJ 2253 Frogger(Dijkstra变形)

POJ 2253 FroggerFreddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty and ful

2017-03-06 22:25:04 245

原创 POJ 2387 Til the Cows Come Home(Dijkstra,重边)

Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she wants to get b

2017-03-05 16:30:30 297

原创 POJ 2251(WA)Dungeon Master(三维BFS)

POJ 2251 Dungeon Master三维简单BFSYou are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one

2017-02-20 20:41:44 355

空空如也

空空如也

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

TA关注的人

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