摘要: 按题目的要求做记忆化递归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)
摘要: 本题锻炼字符串的处理 scanf("%s",s) or strstr or strlen 很好的利用,其他没什么好讲的,注意长度刚好80在上一行输出,附代码。View Code 1 #include <stdio.h> 2 #include <string.h> 3 4 char s[100]; 5 6 7 int main(void) 8 { 9 int t,len=0;10 while(scanf("%s",s)!=EOF)11 {12 if(strstr(s,"<br>"))13 {14 pr 阅读全文
posted @ 2012-08-16 10:38 Wheat″ 阅读(124) 评论(0) 推荐(0)
摘要: 这道题WA好多次才通过,中间有很多没考虑到,加上一点小失误,不过算是把题解出来了。这道题的思想是拓扑排序问题,需要考虑的是拓扑排序的结果只能是一种,多种就不能把各个字母的大小比较出来,每次输入一条变就拓扑排序一次。附上代码和测试实例View Code #include "stdio.h"#include "string.h"#define M 100int g[M][M];int q[M],p[M];bool useif[M],h[M];int top=0,n,m;int cr = 0;int tp[M];int q1[M];int fun(){ int 阅读全文
posted @ 2012-07-09 21:51 Wheat″ 阅读(627) 评论(0) 推荐(0)
摘要: View Code #include "stdio.h"#include "string.h"#define M 110const int inf = 0x3f3f3f3f; int t,n,m;int g[M][M];int prim(int ve){ int closest[M]; int next[M]; bool useif = false; int i,j,v,src=0,nmin; for(i=1;i<=n;i++) { closest[i] = g[ve][i]; next[i] = ve; } next... 阅读全文
posted @ 2012-07-09 15:57 Wheat″ 阅读(148) 评论(0) 推荐(0)
摘要: View Code 1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 struct point 5 { 6 int x,y; 7 }; 8 bool multi(point p0,point p1,point p2) 9 { 10 return (p1.x-p0.x)*(p2.y-p0.y)>(p2.x-p0.x)*(p1.y-p0.y); 11 } 12 int mysort1(point a,point b)13 { 14 if(a.y!=b.y) 15 r... 阅读全文
posted @ 2012-07-08 19:00 Wheat″ 阅读(151) 评论(0) 推荐(0)