自定义博客皮肤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

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

原创 poj 3340 Barbara Bennett's Wild Numbers 递归

//poj 3340 //sep9#include using namespace std;typedef __int64 INT;int n;char a[16],b[16];INT dfs(int cur,int pre_state){ if(cur==n){ if(pre_state>0) return 1; else return 0; } i

2015-12-18 16:22:10 554

原创 poj 1465 Multiple 静态节点+余数判重+非STL队列的广搜

//poj 1465//sep9#include #include using namespace std;int n,m,p;int num[16],vis[8192];struct NODE{ int dig,r,pre; }Q[8192];void print(int x){ if(x!=-1){ print(Q[x].pre); printf("%d",

2015-12-16 04:07:27 437

原创 poj 2565 Average is not Fast Enough! 水题

//poj 2565//sep9#include using namespace std;char s[16];int get_second(){ if(s[0]=='-') return -1; int H,M,S; H=s[0]-'0'; M=10*(s[2]-'0')+s[3]-'0'; S=10*(s[5]-'0')+s[6]-'0'; return H*360

2015-12-15 20:01:19 534

原创 poj 3039 Close Encounter “追赶法”搜索

//poj 3039//sep9//similar with poj 1650#include #include using namespace std;const int MAXX=32767;int gcd(int x,int y){ return x%y==0?y:gcd(y,x%y);}int main(){ int n,d,ansn,ansd,x,y; dou

2015-12-15 01:14:47 584

原创 poj 1650 Integer Approximation “追赶法”搜索

题意:给a,l,求n,d分析:两个需要枚举的变量,由于两个变量有依赖关系,可采取“追赶法”,能在O(n)时间解决问题。代码://poj 1650//sep9#include #include using namespace std;int main(){ int n,d,ansn,ansd,l; double a,minx,now,tmp; while(sc

2015-12-14 15:45:17 832

原创 poj 1063 Flip and Shift 冒泡排序的扩展运用

题意:给一个0,1组成的环,问是否可以通过交换间隔为1的两个数使所有1相邻。分析:冒泡排序就是交换相邻2个数可以把任何序列排成升序,用这一性质奇偶讨论下就好。代码://poj 1063//sep9#include using namespace std;int main(){ int cases; scanf("%d",&cases); while(cases

2015-12-14 11:53:38 505

原创 poj 2264 Advanced Fruits dp解LCS的对偶问题

题意:给字符串a,b,求长度最短的包含a且包含b的字符串。分析:是个LCS的对偶问题,dp的方程也很像。代码://poj 2264//sep9#include using namespace std;const int MAXN=128;int dp[MAXN][MAXN],path[MAXN][MAXN];char a[MAXN],b[MAXN];void pr

2015-12-13 23:04:53 477

原创 poj 2649 Factovisors 对n!进行因数分解

//poj 2649//sep9#include #include using namespace std;const int MAXN=50000;bool vis[MAXN+10];int prime[MAXN+10];int n,m,p;vector > exp;void init(){ memset(vis,0,sizeof(vis)); p=0; for(i

2015-12-12 23:49:54 595

原创 poj 3517 And Then There Was One 约瑟夫问题

//poj 3517//sep9#includeusing namespace std;int main(){ int n,k,m; while(scanf("%d%d%d",&n,&k,&m)==3&&(n|m|k)){ int ans=0; for(int i=2;i<n;++i) ans=(ans+k)%i; ans=(ans+m)%n; printf(

2015-12-12 01:37:12 460

原创 poj 1283 Moving Computer dp解小球放小盒

//poj 1283//sep9#include using namespace std;typedef __int64 INT;const int MAXN=200;INT dp[MAXN+10][MAXN+10];int main(){ int N,K; memset(dp,0,sizeof(dp)); for(int i=0;i<=MAXN;++i) dp[i]

2015-12-11 17:33:01 594

原创 poj 2818 Making Change 枚举

//poj 2818//sep9include using namespace std;int Q,D,N,P,C;struct NODE{ int a,b,c,d;};pair mymin(pair x,pair y){ if(x.first<y.first) return x; return y;}void solve(){ NODE x; pair ans=

2015-12-11 17:06:23 568

原创 poj 1240 Pre-Post-erous! 分治

//poj 1240//sep9#include using namespace std;typedef __int64 INT;char x[32],y[32];INT M;INT C(INT n,INT m){ INT ans=1; m=m>(n-m)?(n-m):m; for(INT i=1;i<=m;++i) ans=ans*(n-i+1)/i; retu

2015-12-11 14:50:00 866

原创 poj 1848 Tree 树形dp

//poj 1848//sep9include #include using namespace std;const int MAXN=128;const int INF=100000;vector g[2*MAXN];int dp[MAXN][3];void dfs(int u,int p){ vector son; int sum=0; for(int i=0;i<

2015-12-11 10:42:59 493

原创 poj 1463 Strategic game 树的最小点覆盖

//poj 1463//sep9#include using namespace std;const int MAXN=1600;struct EDGE{ int v,nxt;}edge[MAXN*2];int M,v1,v2,e; bool g[MAXN][MAXN]; bool vis[MAXN]; int link[MAXN]; int head[MAXN

2015-12-11 10:03:42 469

原创 poj 3398 Perfect Service 树形dp类似求树的点最小支配集

//poj 3398//sep9#include #include using namespace std;const int MAXN=10024;vector g[MAXN];int dp[MAXN][3],tmp[MAXN];void dfs(int u,int p){ if(g[u].size()==1&&g[u][0]==p){ dp[u][0]=1; dp

2015-12-10 19:31:15 498

原创 poj 3659 Cell Phone Network 树的最小点支配集

题意:给一棵树,求它的最小点支配集。分析:树形dp,注意点支配集与点覆盖集的区别是点支配集是覆盖所有的点,点覆盖集是覆盖所有的边,看看这组数据就知道为什么每个点有3个状态了:111 21 31 41 53 66 77 87 97 107 11代码://poj 3659//sep9#include #include using namesp

2015-12-10 17:06:58 551

原创 poj 2361 Tic Tac Toe 五子棋模拟

//poj 2361//sep9//与poj3075的区别是在游戏中的状态也合法#include #include using namespace std;int way[8][3]={ {0,1,2}, {3,4,5}, {6,7,8}, {0,3,6}, {1,4,7}, {2,5,8}, {0,4,8}, {2,4,6}};char s[16];b

2015-12-10 10:00:22 974 1

原创 poj 3075 Tic-Tac-Toe 五子棋模拟

//poj 3075//sep9#include #include using namespace std;int way[8][3]={ {0,1,2}, {3,4,5}, {6,7,8}, {0,3,6}, {1,4,7}, {2,5,8}, {0,4,8}, {2,4,6}};char s[16];bool check(char c){ for(

2015-12-10 09:41:54 1124

原创 poj 1140 Expanding Fractions 除法模拟

//poj 1140//sep9#includeusing namespace std;int vis[1024];void solve(int a,int b){ int cnt=0,t=0; memset(vis,-1,sizeof(vis)); vis[a]=cnt++; a*=10; printf("."); while(1){ printf("%d",a/

2015-12-06 15:33:21 551

原创 poj 1555 Polynomial Showdown 模拟

//poj 1555//sep9#include using namespace std;char s[10024];int a[10024];int main(){ while(gets(s)){ int cnt=0; for(int i=0;s[i]!='\0';){ int p=1; while(!(s[i]='0')){ if(s[i]=='-

2015-12-05 09:04:37 410

原创 poj 3239 Solution to the n Queens Puzzle n皇后问题的构造解法

#include using namespace std;int n;int main(){ while(scanf("%d",&n)==1&&n){ if(n%6!=2&&n%6!=3){ for(int i=2;i<=n;i+=2) printf("%d ",i); for(int i=1;i<=n;i+=2) printf("%d ",i);

2015-12-04 17:26:07 568

原创 poj 1127 Jack Straws 并查集+线段规范相交的判断

//poj 1127//sep9#include using namespace std;struct P { int x,y; }p[128]; int f[32];int det(P a,P b,P c) { int x1=b.x-a.x; int y1=b.y-a.y; int x2=c.x-a.x; i

2015-12-04 11:30:58 416

原创 poj 3629 Card Stacking 模拟队列

//poj 3629//sep9#include #include #include #include using namespace std;int n,k,p,m;list l;int x,y;int q[6000000];void print(int x){ printf("%d\n",x); }int main(){ scanf("%d%d%d",&n

2015-12-04 10:03:47 836

原创 poj 1178 Camelot 枚举

//poj 1178//sep9#include using namespace std;char s[132];int da[8][2]={ {-2,-1},{-2,1},{-1,-2},{-1,2}, {2,1},{2,-1},{1,2},{1,-2} };int db[8][2]={ {-1,-1},{-1,0},{-1,-1},{0,-1}, {0,1},{1,-1}

2015-12-04 09:08:27 510

原创 poj 1365 Prime Land 素因数分解

//poj 1365//sep9#include #include using namespace std;const int MAXN=32767;int tot,vis[MAXN+10],prime[MAXN+10];char s[128];void solve(int sum){ --sum; stack > sta; for(int j=0;j<tot;++j)

2015-12-03 22:02:01 452

原创 poj 1155 TELE 树形dp泛化背包

//poj 1155//sep9#include #include using namespace std;const int MAXN=3012;int n,m,ans;struct Node{ int v,w;};vector g[MAXN];int num[MAXN],dp[MAXN][MAXN];void dfs(int u){ for(int i=g[u].

2015-12-03 12:17:12 562

原创 poj 1186 方程的解数 折半枚举+hash

//poj 1186//sep9#include using namespace std;const int HASHLEN=1000023;const int MAXNODENUM=4000024;int n,m,ans,e,tag;int k[32],p[32];int head[HASHLEN+10];struct Node{ int val,cnt,nxt;}edg

2015-12-02 22:44:40 693

空空如也

空空如也

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

TA关注的人

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