自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

sepNINE的专栏

As brief as possible

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

原创 poj 1739 Tony's Tour 插头dp模板题

题意:给一个迷宫,求左下角到右下角的路径数。分析:插头dp的模板题,建议先看cdq的论文再看代码,这份代码在模板基础上略微有改动。论文地址http://wenku.baidu.com/view/ed2b3e23482fb4daa58d4b74.html代码:#include using namespace std;const int maxD=16;const int H

2015-07-23 11:03:06 1293

原创 poj 2932 Coneology 扫面线法

题意:给n个无交点的圆,求这n个圆中不被其它圆包含的圆。分析:扫面线法,用二叉树(set+lowerbound方法)维护最外圆的集合。代码://poj 2932//sep9#include #include #include #include using namespace std;const int maxN=40012;double r[maxN],x[ma

2015-07-08 15:45:34 1417

原创 poj 1845 Sumdiv 矩阵法求幂的和

题意:给A,B,求A^B所有因子模9901的和(0 分析:因素分解后关键是求1+p^1+p^2+....p^k的和,因为等比数列和公式涉及除法,不用乘法逆元的话不能直接用公式。设s(k+1)=p^0+p^1+...p^k,s0=0,则然后就能2分幂快速求了。代码:

2015-07-08 11:40:49 736

原创 poj 1941 The Sierpinski Fractal 递归

//poj 1941//sep9#include using namespace std;const int maxW=2048;const int maxH=1024;int pow2[32];char g[maxH+10][maxW+10];void print(int x,int y,int n){ if(n==1){ g[x][y+1]='/'; g[x][y+

2015-07-07 08:05:38 2419

原创 poj 2038 Team Rankings 枚举排列

//poj 2038//sep9#include #include using namespace std;char s[128][8];int count(char s1[],char s2[]){ int cnt=0; for(int i=0;i<5;++i) for(int j=i+1;j<5;++j){ int k; for(k=0;k<5;++k)

2015-07-06 10:21:48 982

原创 poj 2556 Edge 向量旋转

//poj 2556//sep9#includeusing namespace std;char s[256];int main(){ while(scanf("%s",&s)==1){ int px=300,py=420; int x=310,y=420; puts("300 420 moveto\n310 420 lineto"); for(int i=0;s[

2015-07-05 23:02:00 1146

原创 poj 3105 Expectation 按位统计

题意:给n,求sum(i^j)/(n^2),0分析:暴力n^2算法肯定超时。这是logn按位统计算法:按位先算出0出现的个数x,则1出现的个数为n-x,再算每位对和的贡献。代码://poj 3105//sep9#include using namespace std;int main(){ int cases; scanf("%d",&cases); whil

2015-07-05 21:27:37 891

原创 poj 2660 War on Weather 计算几何

//poj 2660 //sep9#include #include using namespace std;const double pi=acos(-1.0);const double radius=20000.0/pi;struct P{ double x,y,z,angle;}satellite[128];double dist(double x,double y

2015-07-05 18:41:13 724

原创 poj 2945 Find the Clones trie树的简单应用

题意:给n个长m的字符串,统计他们的出现频率,输出出现1次的有几种,出现2次的有几种...出现n次的有几种。n分析:也可以用排序,map水的,但还是写个trie树也不麻烦,trie树我就得就是针对字符串的hash表,效率如果数据大点是比暴力解法高很多的,另外写的时候不小心把index定义成char,n代码://poj 2945//sep9#include using na

2015-07-05 12:16:59 673

原创 poj 2955 Brackets dp简单题

//poj 2955//sep9#include using namespace std;char s[128];int dp[128][128];int n;int rec(int l,int r){ if(dp[l][r]!=-1) return dp[l][r]; if(l==r) return dp[l][r]=0; if(l+1==r){ if(s[l

2015-07-05 10:44:44 671

原创 poj 3071 Football 概率dp

题意:有2*n只队伍参加n论的淘汰赛,给出任意两只队伍交战的各自的胜率,求最后剩下概率最高的队伍。分析:概率dp,dp[i][j]表示第i轮结束后队伍j还在场上的概率,dp[i][j]=dp[i-1][j]*sum(dp[i-1][k]p[j][k])(1>i==(k-1)>>i&&(j-1)>>(i-1)!=(k-1)>>(i-1),把每个队的id用二进制写出来画画图就知道为什么这样

2015-07-04 00:16:56 1276

原创 poj 2780 Linearity 最多共线点经典问题

题意:给n个点,其中最多有多少点共线(n分析:这是一个经典问题,朴素n^3解法:枚举n^2条直线,判断每条直线与多少点相交,复杂度n^3。明显会超时。这是n^2logn的解法:枚举每个点,对某个点与其他点连的n条直线按斜率排序,设这些直线中斜率相同的直线有k条,则k更新答案。这里想着重说一下斜率的问题,网上很多代码都是直接算斜率的,但计算几何的题目不推荐用斜率,最好用叉积代替有关斜率的

2015-07-03 20:36:36 1837 1

原创 poj 2193 Lenny's Lucky Lotto Lists 简单dp

//poj 2193//sep9#include using namespace std;typedef __int64 INT;INT dp[16][2048];int n,m;int main(){ int cases,t=0; scanf("%d",&cases); while(cases--){ scanf("%d%d",&n,&m); memset(dp,0

2015-07-03 01:19:03 1414

原创 poj 4014 Dice 贪心

//poj 4014//sep9#include #include using namespace std;int n;struct DICE{ int ids; int num; int a[128];}d[1024];int cmp1(DICE x,DICE y){ return x.num<y.num;}int cmp2(DICE x,DICE y){

2015-07-02 22:29:59 862

原创 poj 4016 Flat 水题

#include using namespace std;int main(){ int n,c,area=0,bed_area=0,bal_area=0; scanf("%d%d",&n,&c); while(n--){ int x; char s[16]; scanf("%d%s",&x,s); area+=x; if(strcmp(s,"bedroom")=

2015-07-02 11:31:31 940

原创 poj 1694 An Old Stone Game 树形dp

//poj 1694//sep9#include #include using namespace std;const int maxN=256;int n;int tree[maxN][maxN];int ans[maxN];int cmp(int a,int b){ return a>b;}int dfs(int u){ int tmp[maxN],t=0; i

2015-07-02 10:57:48 881

原创 poj 1021 2D-Nim 模拟

题意:给两个平面,每个平面上有一些点,相邻的点可构成点集,为两个平面内的点集是够都对应相似。两个点集相似是指经过对称或旋转或平移后相等。分析:直接模拟判断。代码://poj 1021//sep9#include #include #include using namespace std;int w,h,n;int g[128][128];int vis[128]

2015-07-01 12:28:19 933

原创 poj 2960 S-Nim nim博弈grundy值计算法入门

题意:给k堆石子,两人轮流向某一堆中拿,拿的个数要从给定的一个集合中取,没石子拿的输,问先手必胜还是必败。分析:grundy值计算法的入门题。代码://poj 2960//sep9#include #include using namespace std;int s[128];int grundy[10024];int maxx;int num;int get

2015-07-01 10:13:24 985

原创 poj 1671 Rhyme Schemes 第二类Stirling数

题意:求s(n,0)+s(n,1)+...s(n,n),s(i,j)为第二类Stirling数。分析:有递推公式s(p,k)=(p-1)*s(p-1,k)+s(p-1,k-1) ,1代码://poj 1671//sep9#includeusing namespace std;double s[64][64];double sum[64];int main(){

2015-07-01 09:33:02 846

空空如也

空空如也

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

TA关注的人

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