上一页 1 ··· 4 5 6 7 8
摘要: 泪奔啊!原来STL中的queue那么慢..改了一下午还以为是算法错了呢..#include<stdio.h>#include<string.h>#define inf 0x3f3f3f3fstruct node{ int x,y,step;}a[1000000];int vis[40000][2],ar[201][201],ans[201][201][2],x,y,n;void bfs(int x){ int i,row,col,front=0,tail=1; int dir[4][2]={0,1,1,0,-1,0,0,-1}; while(front!=tail) { 阅读全文
posted @ 2011-10-21 21:28 104_gogo 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 又水了道题,罪过..#include <stdio.h>#include <string.h>int n,m;char board[100][100];int dfs(int x,int y,int num,int d){ int i,row,col,dir[4][2]={0,1,1,0,0,-1,-1,0}; if (num==n*m)return 1; for (i=d;;i++) { row=x+dir[i%4][0]; col=y+dir[i%4][1]; if(row>=0&&col>=0&&row<n& 阅读全文
posted @ 2011-10-21 13:43 104_gogo 阅读(231) 评论(0) 推荐(0) 编辑
摘要: 有点繁杂的一道题,不过还是耐心的A了它,真开心~~注意输出,题目要求不大于最大整数,也是就说如果是3.5,输出3,如果是-3.5,输出-4.#include <stdio.h>#include <math.h>int main(){ int T,a,X,Y,flag; char s[300],*p,*q; scanf("%d",&T); while (T--) { scanf("%s",s); q=p=s; X=Y=0; flag=1; while (flag)//‘=’前部分 { a=0; if (*p>=' 阅读全文
posted @ 2011-10-21 11:51 104_gogo 阅读(281) 评论(0) 推荐(0) 编辑
摘要: dfs#include <iostream>#include <algorithm>using namespace std;int ar[25],n,b,ans=0x3f3f3f3f;void dfs(int i,int high){ int j; if (high>=b) { if (high<ans)ans=high; return; } for (j=i;j<n;j++) { dfs (j+1,ar[j]+high); }}int main(){ int i,j; cin>>n>>b; for (i=0;i<n;i+ 阅读全文
posted @ 2011-10-20 22:28 104_gogo 阅读(121) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>int min(int a,int b,int c){ if(a<=b&&a<=c)return a; if(b<=a&&b<=c)return b; if(c<=a&&c<=b)return c;}int main(){ int n,i,j=1,k=1,l=1,ans[1505]; ans[1]=1; for (i=2;i<=1500;i++) { ans[i]=min(ans[j]*2,ans[k]*3,ans[l]*5); if(ans[i]==ans 阅读全文
posted @ 2011-10-20 22:00 104_gogo 阅读(167) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <stdlib.h>int cmp(const void *x,const void *y){ return *(int *)x-*(int *)y;}int Min(int a,int b){ return a<b?a:b;}int main(){ int ar[1001],n,i,min,m; scanf("%d",&m); while (m--) { scanf("%d",&n); for(i=0;i<n;i++)scanf("%d& 阅读全文
posted @ 2011-10-20 21:46 104_gogo 阅读(107) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8