雕刻时光

just do it……nothing impossible
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
上一页 1 ··· 39 40 41 42 43 44 45 46 47 ··· 50 下一页

2011年3月30日

摘要: 每搜到结果就随时在ji[]记录num是搜到的步数View Code #include<stdio.h>bool map[109][109];int ji[109],n,num;bool v[109];bool ok;void dfs(int s){ int ts,i; if(ok==1) return ; if(num==n) { ok=1; return ; } for(i=1;i<=n;i++) { if(map[s][i]==1&&v[i]==0) { num++; ji[num]=i; v[i]=1; dfs(i); if(ok==1) return 阅读全文

posted @ 2011-03-30 16:23 huhuuu 阅读(215) 评论(0) 推荐(0) 编辑

2011年3月27日

摘要: 直接枚举整数算余数 明显会超时枚举(小数+整数) 求方后四舍五入,后求根号后比较小数,看是否一致即可注意:费解的精度问题如:对219048452111求根号,然后对求得的数进行*10运算,到后来开始的第九位小数会变化,由4到3的变化?解决方法,直接乘1000,000,000后求第9位数View Code #include<stdio.h>#include<math.h>int main(){ __int64 l,s,j; __int64 i,n,t1; while(scanf("%I64d%I64d",&l,&s)!=EOF) { d 阅读全文

posted @ 2011-03-27 21:31 huhuuu 阅读(555) 评论(0) 推荐(0) 编辑

2011年3月24日

摘要: 咋一看还以为是,求森林里树的最小和实际增加0点就是求最小生成树了……View Code #include<stdio.h>int map[309][309];int dis[309];int p[309];bool use[309];int n;void krus(){ int i,min,rj,j; for(i=0;i<=n;i++) { use[i]=0; dis[i]=map[0][i]; } use[0]=1; int add=0; for(i=0;i<n;i++) { min=99999999; for(j=0;j<=n;j++) { if(use[j] 阅读全文

posted @ 2011-03-24 20:49 huhuuu 阅读(623) 评论(0) 推荐(0) 编辑

摘要: 先写个暴力的找找规律暴力:View Code看看1到18的数据有规律可循奇数到偶数时是原来的奇数累积的+奇数第几位/2偶数到奇数是(前面的奇数第几位/2)*前面的奇数第几位View Code #include<stdio.h>int main(){ int n; while(scanf("%d",&n)!=EOF) { int i,add=0,j=0; for(i=4;i<=n;i++) { if(i%2==0) { j++; add+=j; } else { add+=j*(i-2); } } printf("%d\n",ad 阅读全文

posted @ 2011-03-24 15:04 huhuuu 阅读(509) 评论(0) 推荐(0) 编辑

2011年3月23日

摘要: dp[i]=min(dp[i],dp[j]+dp[i-j]+m)//dp [i]里放着i只牛渡河最少时间View Code #include<stdio.h>int dp[2509];int a[2509];int min(int a,int b){ return a>b?b:a;}int main(){ int n,m; while(scanf("%d%d",&n,&m)!=EOF) { int i,add=0; for(i=1;i<=n;i++) { int temp; scanf("%d",&temp 阅读全文

posted @ 2011-03-23 22:23 huhuuu 阅读(361) 评论(0) 推荐(0) 编辑

摘要: dp[i][j][k]记录在i,j格子里,剩下k步可以到达终点的路径条数View Code #include<stdio.h>#include<iostream>#include<math.h>using namespace std;bool map[109][109];int fa,fb,ea,eb,add;int f[4][2]={0,-1,-1,0,0,1,1,0};int dp[109][109][19];int n,m,all;int dfs(int a,int b,int step){ if(dp[a][b][step]!=-1)return d 阅读全文

posted @ 2011-03-23 20:48 huhuuu 阅读(402) 评论(0) 推荐(0) 编辑

摘要: 无限RE后,换了个oj提交,AC了DFS搜索的关键是,找到下一步的方向,与准确的回朔View Code #include<stdio.h>int map[129][129];int Max,n;int f[4][2]={{0,-1},{-1,0},{0,1},{1,0}};void dfs(int a,int b,int step){ if(step>Max) Max=step; int sa,sb,i,j; for(i=0;i<=3;i++) { sa=a+f[i][0]; sb=b+f[i][1]; int ta=sa,tb=sb,sstep=step; if(ta 阅读全文

posted @ 2011-03-23 16:03 huhuuu 阅读(249) 评论(0) 推荐(0) 编辑

2011年3月22日

摘要: 注意精度高点没错的View Code #include<stdio.h>#include<math.h>#define R 6378.00#define PI 3.1415926535#define hu 360/3.1415926535/2int main(){ int t; double x1,y1,z1,x2,y2,z2,th1,th2,a1,a2,dis,q; scanf("%d",&t); while(t--) { double a=sin(30/hu); scanf("%lf%lf%lf%lf",&th 阅读全文

posted @ 2011-03-22 14:16 huhuuu 阅读(229) 评论(0) 推荐(0) 编辑

2011年3月18日

摘要: G++提交会超时,C++不会超时View Code #include<iostream>#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int main(){ int a[209],n,m,t,i; scanf("%d",&t); bool use; while(t--) { use=0; scanf("%d%d",&n,&m); for(i=0;i<n;i++) scanf(& 阅读全文

posted @ 2011-03-18 17:19 huhuuu 阅读(330) 评论(0) 推荐(0) 编辑

摘要: 用到STL里的next_permutation(&a[0],&a[le])//说明a[0]->a[le-1]是自由排列的View Code #include<iostream>#include<string.h>#include<algorithm>using namespace std;bool cmp(char a,char b){ return a<b;}int main(){ char a[209]; while(gets(a)) { int le=strlen(a); sort(&a[0],&a[le], 阅读全文

posted @ 2011-03-18 16:28 huhuuu 阅读(764) 评论(0) 推荐(0) 编辑

上一页 1 ··· 39 40 41 42 43 44 45 46 47 ··· 50 下一页