
刘汝佳-《算法竞赛入门模板总结》
L-qf
这个作者很懒,什么都没留下…
展开
-
竞赛篇-----最大连续和问题
1)首先最简单的就是模拟时间复杂度是O(n^3)/*最大连续和问题O(n^3)*/#include<cstdio>#include<iostream>using namespace std;int main() { int a[1005],n,sum,ans; while(~scanf("%d",&n)) { for(int i=1; i...原创 2018-08-28 18:37:20 · 221 阅读 · 0 评论 -
竞赛篇----归并排序顺带求逆序数
/*归并排序实现 求逆序数 O(nlogn)*/#include<cstdio>#include<iostream>#include<algorithm>#define N 1005using namespace std;int a[N],t[N],cnt;void merge_sort(int *a,int x,int y,int *t)...原创 2018-08-28 20:11:42 · 196 阅读 · 0 评论 -
竞赛篇-----二分查找
/*二分查找,左闭右开区间注意查找的数组一定是有序的*/#include<cstdio>#include<iostream>#include<algorithm>#define N 1005using namespace std;int a[N];int bsearch(int *a,int x,int y,int val) { int ...原创 2018-08-28 20:15:58 · 316 阅读 · 0 评论 -
UVA-1152 (二分) 4 Values whose Sum is 0
The SUM problem can be formulated as follows: given four lists A, B, C, D of integer values, compute how many quadruplet (a, b, c, d) ∈ A × B × C × D are such that a + b + c + d = 0. In the following,...原创 2018-09-04 17:00:17 · 213 阅读 · 0 评论 -
UVA-11134 Fabled Rooks (贪心)
We would like to place n rooks, 1 ≤ n ≤ 5000, on a n × n board subject to the following restrictions• The i-th rook can only be placed within the rectangle given by its left-upper corner (xli , yli)...原创 2018-09-05 17:46:48 · 261 阅读 · 0 评论 -
UVA-120Stacks of Flapjacks
Stacks and Queues are often considered the bread and butter of data structures and find use in architecture, parsing, operating systems, and discrete event simulation. Stacks are also important in the...原创 2018-09-03 20:46:39 · 346 阅读 · 0 评论 -
UVA-1605 Building for UN
The United Nations has decided to build a new headquarters in Saint Petersburg, Russia. It will have a form of a rectangular parallelepiped and will consist of several rectangular floors, one on top o...原创 2018-09-03 21:16:24 · 155 阅读 · 0 评论 -
UVA-11572 Unique Snowflakes (STL)
Emily the entrepreneur has a cool business idea: packaging and selling snowflakes. She has devised a machine that captures snowflakes as they fall, and serializes them into a stream of snowflakes that...原创 2018-09-07 09:43:28 · 233 阅读 · 0 评论