摘要: 简单的广搜题目,单广能过,可以拿这题练习双广单广:View Code 1 #include <stdio.h> 2 #include <string.h> 3 4 int n; 5 int x1,y1,x2,y2; 6 int array[2][8] = {{-1, -1, -2, -2, 2, 2, 1, 1},{-2, 2, 1, -1, 1, -1, 2, -2}};//表示马跳的8个方向 7 int q[100000][3]; 8 bool h[310][310]; 9 void bfs()10 {11 int i,sd,ed;12 int x,y,a,b,c; 阅读全文
posted @ 2012-08-18 17:23 Wheat″ 阅读(151) 评论(0) 推荐(0)
摘要: 题目意思:骑士游历的问题咯,单向广搜能过,也可以拿来练习双向广搜咯,附双向广搜代码View Code 1 #include <iostream> 2 #include <queue> 3 #include <cstdio> 4 using namespace std; 5 #define MAX 10 6 struct Status // 结构 7 { 8 int x,y; //位置 9 int vis; 10 }; 11 int visited[MAX][MAX];//标记数组 12 int dir[8][2]={{-2, -1}, {-2, 1... 阅读全文
posted @ 2012-08-18 17:13 Wheat″ 阅读(152) 评论(0) 推荐(1)
摘要: 按题目的要求做记忆化递归View Code 1 #include <stdio.h> 2 #include <string.h> 3 int vis[21][21][21]; 4 5 int w(int a,int b,int c) 6 { 7 if(a <= 0 || b <= 0 || c <= 0) 8 return 1; 9 else if(a > 20 || b > 20 || c > 20)10 return w(20,20,20);11 else if(vis[a][b][c] > 0)12 return... 阅读全文
posted @ 2012-08-18 17:08 Wheat″ 阅读(118) 评论(0) 推荐(0)
摘要: DFS搜索由大的数往小的数View Code 1 #include <stdio.h> 2 #include <string.h> 3 int ans,n,a[1001]; 4 int b[1010]; 5 bool f; 6 void dfs(int v,int t,int g) 7 { 8 int i; 9 if(v==ans)10 {11 f = true;12 for(i=1;i<t-1;i++)13 printf("%d+",b[i]);14 printf("%d\n",b[t-1]);... 阅读全文
posted @ 2012-08-18 17:07 Wheat″ 阅读(108) 评论(0) 推荐(0)
摘要: 一道几何题:设小圆半径为r,大圆为R,有图得 :R = r + r / sin(A);A = 2 * PI / (n * 2) = PI / n;联合得:r == R / ( 1 + ( 1 / sin( 2 * asin(1.0) /n)));PI = 2 * asin(1.0) 可以解决精度的问题View Code 1 #include <stdio.h> 2 #include <math.h> 3 int main(void) 4 { 5 int n,t; 6 double r1,r2; 7 scanf("%d",&n); 8 for( 阅读全文
posted @ 2012-08-18 16:07 Wheat″ 阅读(85) 评论(0) 推荐(0)
摘要: 水题:求各个因子的和,再同n比较,小于输出DEFICIENT,等于输出PERFECT,大于输出ABUNDANT,附代码。#include <stdio.h>#include <string.h>int main(void){ int i,sum,n; puts("PERFECTION OUTPUT"); while(scanf("%d",&n)!=EOF && n) { printf("%5d ",n); sum = 0; for(i=1;i<n;i++) if(n%i==0) s 阅读全文
posted @ 2012-08-18 15:19 Wheat″ 阅读(110) 评论(0) 推荐(0)