摘要: typedef struct BST { int key; BST *left; BST *right;}BST;BST *root;void insert(BST *ROOT,int key){ BST *p,*f; p = ROOT; f = NULL; while ( p != NULL ) { if ( key < p->key ) { f = p; p = p->left; } else { f = p... 阅读全文
posted @ 2012-12-21 21:19 Sinker 阅读(133) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <stdlib.h>#include <time.h>#include <string.h>#define K 10const int MAXN = 10000000;int N;int x[MAXN],y[MAXN];void insert_sort(int a[],int l,int r){ int key; for (int i = l + 1; i <= r; i++) { key = a[i]; for (int j = i - 1; a[j] > key &&a 阅读全文
posted @ 2012-12-19 20:02 Sinker 阅读(163) 评论(0) 推荐(0) 编辑
摘要: /* ID:chenjiong PROG:money LANG:C++*/#include <stdio.h>#include <string.h>int V,N;int m[30];int sum;long long cnt;void dfs(int cur,int s){ if ( sum > N ) return; if ( sum == N ) { cnt++; return; } int i; for ( i = s; i < V; i++) { sum += m[i... 阅读全文
posted @ 2012-11-13 17:05 Sinker 阅读(89) 评论(0) 推荐(0) 编辑
摘要: /* ID:chenjiong PROG:zerosum LANG:C++*/#include <stdio.h>#include <string.h>#include <stdlib.h>char ans[20];int N;char tmp[9][9];int x,y;void init(){ int i; for ( i = 0; i < N; i++) ans[2 * i] = i + 1 + '0'; ans[N + N - 1] = '\0';}void pre(){ int i; tmp[x][y++] = 阅读全文
posted @ 2012-11-13 15:37 Sinker 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 由搜索过渡到dp的方法就是将考察的对象由搜索的单层转变为当前层之前所有层构成的整体。/* ID:chenjiong PROG:subset LANG:C++*/#include <stdio.h>#include <string.h>const int MAXN = 40;int N;int dp[MAXN][MAXN * MAXN];int sum;void solve(){ int i,j; dp[1][1] = 1; dp[1][0] = 1; for ( i = 2; i <= N; i++) { for ( j = 0; ... 阅读全文
posted @ 2012-11-12 23:04 Sinker 阅读(130) 评论(0) 推荐(0) 编辑
摘要: don't get accustomed to thinking of problems in a complicated way./* ID:chenjiong PROG:preface LANG:C++*/#include <stdio.h>#include <string.h>char* table[4][9] = { {"I","II","III","IV","V","VI","VII","VIII&quo 阅读全文
posted @ 2012-11-09 13:21 Sinker 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 1.函数绘图语言只包含四种语句:(1)平移语句:ORIGIN IS (x,y);(2)旋转语句:ROT IS x;(3)比例设置语句:SCALE IS (x,y);(4)循环绘图语句:FOR T FROMstart TOend STEPlen DRAW(x,y);2.注释为单行注释,以//或--开始3.不难发现,在函数绘图语言中没有提供用户自定义变量的语句,于是我们可以归纳出函数绘图语言中三种记号:关键字,关键符号和数值字面量。4.记号的识别(1)数值字面量 = digit(digit)*((.digit(digit)*)?),转义后为浮点数。(2)关键符号 = + |-| -- | * | 阅读全文
posted @ 2012-11-05 22:49 Sinker 阅读(123) 评论(0) 推荐(0) 编辑
摘要: /* ID:chenjiong PROG:runround LANG:C++*/#include <stdio.h>#include <string.h>int val[9];int cnt;int vis[10];void write(unsigned int x){ if ( x / 10 > 0 ) write( x / 10 ); vis[x % 10]++; val[cnt++] = x % 10;}bool is_ok(unsigned int x){ memset(vis,0,sizeof(vis)); cnt = 0... 阅读全文
posted @ 2012-11-05 14:27 Sinker 阅读(149) 评论(0) 推荐(0) 编辑
摘要: /* ID:chenjiong PROG:lamps LANG:C++*/#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;int N;int lamp[7] = {1,1,1,1,1,1,1};int C;int cnt_on;int on[7];int cnt_off;int off[7];bool vis[7];typedef struct { int lamp[7]; int val;}S;int cnt;S ans[16];int w[7] = 阅读全文
posted @ 2012-11-03 19:34 Sinker 阅读(139) 评论(0) 推荐(0) 编辑
摘要: /* ID:chenjiong PROG:subset LANG:C++*/#include <stdio.h>#include <string.h>const int MAXN = 40;int N;int set[MAXN];int sum;int cnt;void init(){ int i; scanf("%d",&N); for ( i = 0; i < N; i++) set[i] = i + 1;}void dfs(int cur){ if ( cur == N ) { if ( sum == N * (... 阅读全文
posted @ 2012-11-02 22:06 Sinker 阅读(119) 评论(0) 推荐(0) 编辑