![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
ACM
文章平均质量分 78
大多多
脚踏实地,仰望星空。
展开
-
Berland National Library(模拟题目)
Red and Black Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u Submit Status Description There is a rectangular room, covered with square tiles. Each tile is colore原创 2016-02-24 17:13:08 · 444 阅读 · 0 评论 -
HDU-1285【拓补排序】
自己学到拓补排序找到这个题目,看着挺简单,其实有一些坑点,结果wrong了很多次,不过还好最终做了出来。 #include #include #include using namespace std; int n,m; int graph[550][550]; int value[550]; int indegree[550]; void tuobu() { int Count=原创 2016-09-13 17:17:14 · 246 阅读 · 0 评论 -
欧拉函数模板
void init() { int i,j; for (i=1;i<N;i++) e[i]=i; for (i=2;i<N;i++) if (e[i]==i) { e[i]=i-1; for (j=i*2;j<N;j+=i) e[j]=e[j]/i*(i-1); } }原创 2016-08-13 14:04:06 · 206 阅读 · 0 评论 -
LightOJ 1097 - Lucky Number(线段树)
做了好多天的线段树基础题目,对线段树有了个大体的了解,上个代码,仅此纪念一下。 /*天王盖地虎,宝塔镇河妖,如来庇佑,佛祖让道,过过过!!*/ #include #include #include #include #include #include #define maxn 820000 #define MAX 1429431 using namespace std; s原创 2016-08-14 20:22:27 · 365 阅读 · 0 评论 -
poj-3397【线段树区间合并】
不得不说线段树的问题代码真太长。。。。。。 这个问题大意刚开始给出一个区间内的数,要么是0要么是1; 然后有如下操作: 0 i j:把区间i到j内的数全部变成0 1 i j:把区间i到j内的数全部变成1 2 i j:把区间i到j内的数0变成1,1变成0 3 i j:把区间i到j内的所有的1求出来 4 i j:求出区间i到j内最大连续的1; 这个问题的关键其实是操作2,因为这涉及到原创 2016-10-22 21:09:33 · 373 阅读 · 0 评论 -
二分图的最大匹配完美匹配
咳咳,,,我是真感觉这两篇文章写得好。。。。。好的东西直接拿过来需要的时候直接看吧。。。 http://www.renfei.org/blog/bipartite-matching.html http://blog.csdn.net/hackbuteer1/article/details/7398008 感谢两位大神。。。。转载 2016-09-28 17:21:44 · 820 阅读 · 0 评论 -
poj2104[划分树问题]
这个题目的意思是给你一个区间,让你找到在某个给出的子区间当中第k大的数。 这是我的第一个划分树题目,因为之前做了好多线段树的题目了,看了看书上基本的代码,然后按照自己的思路写了出来。 按照这个题目的思路,得用到二分,把给出的元素x[n]排好序y[n],对于一个给出的子区间,那么第k大的元素应该满足两点: (1)在区间当中至少存在k个不超过第k大的元素 (2)在区间当中小于第k大的元素不到k原创 2016-10-25 15:46:34 · 213 阅读 · 0 评论 -
坐标的离散化
n*m的格子上画了l条水平或者竖直的直线,求这些线将这些格子化成了多少区域。 具体的数据范围看挑战程序设计竞赛这本书,这个题目的数据范围比较大,所以的话需要将坐标离散化。作用就是将区间的大小变小而且不影响数据的结果。 可是这本书给的数据太坑,根本没有起到离散化的作用。。。。 #include #include #include #include #include #define max原创 2016-10-15 21:40:41 · 1741 阅读 · 0 评论 -
poj-3723【图的最小生成树+并查集】
这个题目做的时候知道是最小生成树,用的kruskal算法,结果在并查集的地方出问题了。 刚开始的same函数弄得不对,,,还好,这个题目算是又复习了一下并查集 #include #include #include #include #include #include #include #include #include using namespace std; typedef原创 2016-10-04 19:39:33 · 251 阅读 · 0 评论 -
poj-3159【差分约束+Dijkstra算法的优化】
昨天看图论的时候找到了这么个题目,刚开始不知道查分约束是什么东西,后来在网上学了一下,知道就是求图的最短路径额。。。。。这东西需要好好看看了。 再看这个题目,题意就是给出两点的最大差值,求出1到n的最大差值,刚开始用的一般的方法这个问题超时了,所以用的优先队列,最后ac了。。。(简简单单两行字,这里面全是泪额。。。。。) 上代码。。。。。 #include #include #inclu原创 2016-10-06 10:10:58 · 1195 阅读 · 1 评论 -
欧几里德与扩展欧几里德算法
1.欧几里德算法(辗转相除法) 作用:求两个数的最大公约数。 设两个数为a,b(a>=b),则a,b的最大公约数为gcd(a,b),我先给出代码,然后解释。 int gcd(int a,int b) { if (b==0) { return a; } else { return (b,a%b); } } 给原创 2016-10-07 17:30:37 · 271 阅读 · 0 评论 -
poj-3041【二分图最小顶点覆盖】
自从看了二分图之后,感觉好多题目的解题方法真的跟以往的思维方式不一样了。。。。这可能就是抽象思维吧。 这个题目的意思是在网格中有k个小行星,你的炮弹只能一次只能摧毁一行或者一列的小行星,让你用求出最小的炮弹数目来毁掉这些小行星。 这个题目抽象的地方在炮弹当做顶点把小行星当做边,把发射的光束当做顶点,然后建图。。。。这样建出图之后求这个二分图的最大匹配,因为对于二分图来说, 最小顶点覆盖=最大原创 2016-11-10 15:41:34 · 615 阅读 · 0 评论 -
poj-3281【最大流】
转换成最大流求解,刚开始看最大流,留着当模板 #include #include #include #include #include #include #include #include #define maxn 20 #define Max 0x3f3f3f3f using namespace std; struct node { int to; int原创 2016-11-12 10:52:40 · 470 阅读 · 0 评论 -
线段相交模板
#include #include #include #include #include #include using namespace std; double EPS=1e-10; double add(double a,double b) { if (abs(a+b)<EPS*(abs(a)+abs(b))) return 0; return a原创 2016-11-15 21:34:36 · 258 阅读 · 0 评论 -
包含容斥原理【题目在挑战程序设计竞赛】
题目大意是这样的,给定a1,a2,...am,求从1到n的整数中至少能整除a中一个元素的数有几个? 输入: n =100,m=2; a={2,3}; 输出: 67 输入: n=100,m=3; a={2,3,7} 输出: 72 因为这个学期学的离散,包含容斥原理印象还是挺深的,对这个也挺感兴趣,不知道有多少人在看挑战程序设计竞赛这本书,前面的费马小定理,线性同余方原创 2016-11-23 22:08:44 · 922 阅读 · 0 评论 -
HDU-3790【图的最短路径问题】
自学到图的最短路径,找到这个水题一试,奈何无限次worng,让我开始怀疑人生。。。。。找了一天的bug,终于找到,,,因为算的最后的数在比较过程中可能会超出int造成数据出错,。。。。真是醉了。。。。。把int全部改成longlong就ac了,现在代码写的还不是太简洁,以后补充。。。 #include #include #include #define Max 0x7fffffff usi原创 2016-09-11 22:34:39 · 308 阅读 · 0 评论 -
poj-1258(Agri-Net)【图的最小生成树】
自学的数据结构,中午看到了图论的最小生成树,想着找个题巩固一下,找到了这个,结果一直错一直错,开始怀疑这本书的算法是不是有问题。。。,郁闷了一下午,晚上突然发现codevs上有这个题目,用了点办法截了一组错误数据,终于发现了错在哪,真是粗心呃。。。。。 #include #include #define MAX 0x3f3f3f3f using namespace std; struct n原创 2016-09-09 20:22:44 · 356 阅读 · 0 评论 -
最大公约数和最小公倍数问题(天梯)
题目描述 Description 输入二个正整数x0,y0(2 条件: 1.P,Q是正整数 2.要求P,Q以x0为最大公约数,以y0为最小公倍数. 试求:满足条件的所有可能的两个正整数的个数. 输入描述 Input Description 二个正整数x0,y0 输出描述 Output Description 满足条件的所有可能的两个正整数的原创 2016-02-16 19:18:10 · 306 阅读 · 0 评论 -
Oulipo(kmp算法)
题目意思就是找子串在一个长串中出现的次数。 因为数据较大,一般的做法都超时,看了看kmp算法,用这个算法做的。这个算法最难的就是求那个next数组吧。 #include #include #include #include #include #include #include #include #define Max 1000000000 using namespace std; st原创 2016-07-23 20:22:43 · 315 阅读 · 0 评论 -
Alternating Current
B. Alternating Current time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mad scientist Mike has just finished原创 2016-02-24 17:37:38 · 496 阅读 · 0 评论 -
Rescue(宽搜问题)
Rescue Time Limit: 2000MS Memory Limit: 65536KB 64bit IO Format: %lld & %llu Submit Status Description Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is desc原创 2016-02-24 17:28:08 · 502 阅读 · 0 评论 -
The Suspects(并查集问题)
严重急性呼吸系统综合症( SARS), 一种原因不明的非典型性肺炎,从2003年3月中旬开始被认为是全球威胁。为了减少传播给别人的机会, 最好的策略是隔离可能的患者。 在Not-Spreading-Your-Sickness大学( NSYSU), 有许多学生团体。同一组的学生经常彼此相通,一个学生可以同时加入几个小组。为了防止非典的传播,NSYSU收集了所有学生团体的成员名单。他们的标准操作程序原创 2016-02-24 16:59:33 · 2009 阅读 · 0 评论 -
POJ-2492(并查集问题)
A Bug's Life Time Limit: 10000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64u Submit Status Description Background Professor Hopper is researching the sexual behavior of a rare s原创 2016-02-24 16:56:35 · 415 阅读 · 0 评论 -
New Year and Days
New Year and Days time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Today is Wednesday, the third day of the原创 2016-02-16 13:47:25 · 257 阅读 · 0 评论 -
A. Cookies
A. Cookies time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Fangy collects cookies. Once he decided to take a原创 2016-02-16 13:34:43 · 453 阅读 · 0 评论 -
纵横字谜的答案
纵横字谜的答案 Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status Description Download as PDF Crossword Answers A crossword puzzle consists of a rectangular原创 2016-02-03 16:32:24 · 616 阅读 · 0 评论 -
uva 227 Puzzle
A children's puzzle that was popular 30 years ago consisted of a 5x5 frame which contained 24 small squares of equal size. A unique letter of the alphabet was printed on each small square. Since there原创 2016-02-03 11:22:06 · 307 阅读 · 0 评论 -
WoodenSticks(区间贪心类题目)
Description There is a pile of n wooden sticks. The length and weight of each stick are known in advance. The sticks are to be processed by a woodworking machine in one by one fashion. It needs some原创 2016-02-03 09:22:38 · 475 阅读 · 0 评论 -
1011数的计算
题目描述 Description 我们要求找出具有下列性质数的个数(包含输入的自然数n): 先输入一个自然数n(n 1. 不作任何处理; 2. 在它的左边加上一个自然数,但该自然数不能超过原数的一半; 3. 加上数后,继续按此规则进行处理,直到不能再加自然数为止. 输入描述 Input Des原创 2016-01-31 21:41:42 · 919 阅读 · 1 评论 -
Red and Black(搜索题目)
Red and Black Time Limit: 1000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u Submit Status Description There is a rectangular room, covered with square tiles. Each tile is colore原创 2016-02-24 17:02:05 · 478 阅读 · 0 评论 -
HDU1671(字典树)
第一次做字典树的题目,在网上找了点字典树的知识,把它ac了。。留着以后多巩固巩固。 #include #include #include #include #include #define MAX 10 using namespace std; char x[11]; bool ans; struct tree { bool cmp; tree * next[11]; };原创 2016-08-06 22:22:22 · 242 阅读 · 0 评论 -
我的起点(蛇形矩阵)
题目描述 Description 小明玩一个数字游戏,取个n行n列数字矩阵(其中n为不超过100的奇数),数字的填补方法为:在矩阵中心从1开始以逆时针方向绕行,逐圈扩大,直到n行n列填满数字,请输出该n行n列正方形矩阵以及其的对角线数字之和. 输入描述 Input Description n(即n行n列) 输出描述 Output Descriptio原创 2016-01-29 21:21:04 · 450 阅读 · 0 评论