`
xxx0624
  • 浏览: 31630 次
文章分类
社区版块
存档分类
最新评论
文章列表
先筛出素数,再筛出美素数。 简单题。 /* 筛素数 */ #include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorithm> #include<iostream> #include<queue> #include<stack> #include<math.h> #include<map> using namespace std; const int maxn = 1000005; int IsPri ...
简单题。。。 dp[ i ][ j ] 表示第 i 行取第 j 个数的MinVal /* DP&简单题 */ #include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorithm> #include<iostream> #include<queue> #include<stack> #include<math.h> #include<map> using namespace std; const ...
状态压缩DP 对于某一行的状态可以由前面的两行推出。 即:dp[ i ][ j ][ k ] = max( dp[ i ][ j ][ k ] , dp[ i-1 ][ k ] [ k2 ] + ones[ j ] ); 其中i-1表示前1行,k2是前2行的状态。 /* 题意:n行m列的矩阵,1表示可以放东西,0表示不可以。曼哈顿距离为2的两个位置最多只能有一个位置放东西。 问最多放多少个东西。 */ #include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorit ...
最大团 问题描述:团就是最大完全子图。 给定无向图G=(V,E)。如果UV,且对任意u,vU 有(u,v)E,则称U 是G 的完全子图。 G 的完全子图U是G的团当且仅当U不包含在G 的更大的完全子图中,即U就是最大完全子图。 G 的最大团是指G ...
/* 线段树+扫描线+离散化 求多个矩形的面积 */ #include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorithm> #include<iostream> #include<queue> #include<stack> #include<math.h> #include<map> using namespace std; const int maxn = 105; const int maxm = 21 ...
思路: 以y的值进行离散化 根据x的值 对每一条y轴边进行处理,如果是"左边"则插入,是"右边"则删除。 /* 扫描线+线段树+离散化 求多个矩形的周长 */ #include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorithm> #include<iostream> #include<queue> #include<stack> #include<math.h> #inclu ...
  .3 多边形的扫描转换与区域填充 扫描线算法 扫描线算法是按扫描线顺序,计算扫描线与多边形的相交区间,再用要求的颜色显示这些区间的象素,完成转换工作。区间的端点可以通过计算扫描线与多边形边界线的交点获得。对于一条扫描线,多边形的扫描转换过程可以分为四个步骤: (1)求交:计算扫描线与多边形各边的交点; (2)排序:把所有交点按x值递增顺序排序; (3)配对:第一个与第二个,第三个与第四个等等;每对交点代表扫描线与多边形的一个相交区间, (4)着色:把相交区间内的象素置成多边形颜色,把相交区间外的象素置成背景色。
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorithm> #include<iostream> #include<queue> #include<stack> #include<math.h> #include<map> using namespace std; const int maxn = 115; const int inf = 9999999; char mat[ maxn ][ ma ...
/* 计算过了D天后的日期 之前D天的日期 */ #include<stdio.h> int judge_year( int year ){ if( (year%4==0&&year%100!=0)||(year%400==0) ) return true; else return false; } int judge_month( int mon ){ if( mon==1||mon==3||mon==5||mon==7||mon==8||mon==10||mon==12 ) return t ...
把a,d这两个起点和终点之间的中间点三分出来。 其他没什么。 /* 两次三分 题意:给定abcd四个点(包括速度,位置),从a到d,求最短时间。 */ #include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> #include<algorithm> using namespace std; const int maxn = 105; const double eps = 1e-8; const double pi = acos(-1.0); s ...
模板题,不解释。 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorithm> #include<math.h> using namespace std; const double eps = 1e-8; const int maxn = 100005; const double inf = 9999999999.0; struct Point { double x,y; }; struct Line{ Point a,b; }; Poin ...
只需要特判标记即可 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> #include<algorithm> using namespace std; const double eps = 1e-8; const double inf = 9999999999.0; const int maxn = 100005; struct Point{ double x,y; int flag; }; Point pnt[ maxn< ...
题意:给定一些点,求最大三角形面积 /* 凸包 */ #include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorithm> #include<iostream> #include<queue> //#include<map> #include<math.h> using namespace std; typedef long long ll; //typedef __int64 int64; const int ma ...
题意:求出给定的凸多边形的内接圆 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> #include<algorithm> using namespace std; const int maxn = 155; const int maxm = 1005; const double Min = 0.0; const double Max = 10000000000.0; const double eps = 1e-8; const doub ...
模板题 题意:给定两个凸多边形,求出合并后的面积,这个合并后的面积不包括重叠部分。 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> #include<algorithm> using namespace std; const int maxn = 155; const int maxm = 155; const double eps = 1e-8; const double pi = acos(-1.0); struct Point{ ...
Global site tag (gtag.js) - Google Analytics