afterward

导航

 

2012年8月19日

摘要: View Code #include<iostream>#include<cstring>#include<cstdio>#include<algorithm>using namespace std;const int MM=1000100;long long a[5][205];long long hash[MM];bool counter[MM];int hash_find(long long num){ int t; t=num%MM; if(t<0) t+=MM; while(counter[t] && hash[t 阅读全文
posted @ 2012-08-19 16:50 afterward 阅读(224) 评论(0) 推荐(0) 编辑
 
摘要: View Code #include<iostream>#include<cstdio>#include<queue>using namespace std;char dp[901][8101];//lengthchar d[901][8101];//last digitint main() { for (int i = 1;i <= 9;i++) { dp[i][i * i] = 1; d[i][i * i] = i; } for (int i = 1;i <= 900;i++) { for (int j = i;j <= 8100... 阅读全文
posted @ 2012-08-19 15:21 afterward 阅读(256) 评论(0) 推荐(0) 编辑
 
摘要: 这道题要一步一步来的:(1) n条直线最多分平面问题题目大致如:n条直线,最多可以把平面分为多少个区域。析:可能你以前就见过这题目,这充其量是一道初中的思考题。但一个类型的题目还是从简单的入手,才容易发现规律。当有n-1条直线时,平面最多被分成了f(n-1)个区域。则第n条直线要是切成的区域数最多,就必须与每条直线相交且不能有同一交点。 这样就会得到n-1个交点。这些交点将第n条直线分为2条射线和n-2条线断。而每条射线和线断将以有的区域一分为二。这样就多出了2+(n-2)个区域。故:f(n)=f(n-1)+n=f(n-2)+(n-1)+n……=f(1)+2+……+n=n(n+1)/2+1(2 阅读全文
posted @ 2012-08-19 15:09 afterward 阅读(2581) 评论(0) 推荐(0) 编辑
 
摘要: View Code #include<iostream>using namespace std;bool flag;void DFS(int n,int *A,int *B,int *C){ if(n==0) { flag = true; return ; } if(B[0]&&n==B[1])//n号不会出现在B柱 { flag = false; return ; } if(A[0]&&n==A[1])//n号在A柱上 { A[1]=A[0]-1; DFS(n-... 阅读全文
posted @ 2012-08-19 15:07 afterward 阅读(213) 评论(0) 推荐(0) 编辑