上一页 1 ··· 28 29 30 31 32 33 34 35 36 ··· 42 下一页
不怎么会做这类题目额。。伤,看别人的View Code 1 #include<stdio.h> 2 #include<string.h> 3 #define maxn 1010 4 int dp[maxn][maxn]; 5 int sum[maxn][maxn]; 6 const int mod = 1000000007; 7 int main() 8 { 9 int i,j;10 char s[maxn];11 while(scanf("%s",s)!=EOF)12 {13 int n=strlen(s);14 memset... Read More
posted @ 2011-11-01 21:51 Because Of You Views(350) Comments(0) Diggs(0) Edit
使用了书上讲的迭代加深搜索,假设删除一个点,两个点,三个点。。。每次都先找最短路径再枚举最短路径上的点删除,dfs实现,A的很顺利,呵呵。。View Code 1 #include<stdio.h> 2 #include<string.h> 3 int n,m,k; 4 int tot; 5 bool goal; 6 int fa[60]; 7 bool flag[60]; 8 int d[50][100]; 9 int head[60];10 int Q[10000];11 struct node12 {13 int t,next;14 }edge[10005];15 Read More
posted @ 2011-11-01 21:03 Because Of You Views(480) Comments(4) Diggs(0) Edit
学习自http://blog.csdn.net/dooder_daodao/article/details/6336879View Code 1 #include<stdio.h> 2 #include<math.h> 3 #include<stdlib.h> 4 #include<time.h> 5 const double inf = 1e10; 6 const double pi = acos(-1.0); 7 const int Rp = 4; 8 const int shift = 60; 9 struct point {10 doub Read More
posted @ 2011-10-31 15:39 Because Of You Views(736) Comments(0) Diggs(0) Edit
同 上一题,错了两次,原因:100000*100000会超intView Code 1 #include<stdio.h> 2 #include<string.h> 3 typedef __int64 lld; 4 lld sum[100010]; 5 int mod[100010]; 6 int re[100010]; 7 int num[100010]; 8 inline bool dig(char x){return x>='0'&&x<='9';} 9 int get_val()10 {11 int r Read More
posted @ 2011-10-30 16:28 Because Of You Views(285) Comments(0) Diggs(0) Edit
抽屉原理。。早就知道了,只是没有切过题,今天碰上了一道,果断刷掉其实n个数一定可以找出一些数或某个数的和能被n整除取sum[i]为前i个数的和,对n取余。n个数对n取余,下面两个结论必有一个成立:有两个余数是相等的,有一个余数是1其中任何一个结论的成立都表示存在一些数的和能被n整除View Code 1 #include<stdio.h> 2 #include<string.h> 3 int sum[10010]; 4 int mod[10010]; 5 int re[10010]; 6 int num[10010]; 7 int main() 8 { 9 int n, Read More
posted @ 2011-10-30 16:07 Because Of You Views(319) Comments(0) Diggs(0) Edit
dp[i]表示现在存在i个吸血鬼要达成目标(全为吸血鬼)天数的数学期望假如现在再增加一天,这一天可能会增加一个吸血鬼,p1*(dp[i+1]+1)表示接下来的一天增加了一个吸血鬼,所以为(dp[i+1]+1),还有一种可能就是没有增加吸血鬼,概率自然是(1-p1)dp[i]+1表示接下来的一天没有增加吸血鬼,但向后推移了一天因此dp[i]这个状态可以转移到dp[i+1]+1,概率为p1dp[i]+1 概率为(1-p1)所以dp[i]=(dp[i+1]+1)*p1+(dp[i]+1)*(1-p1);p1是有i个吸血鬼再增加一个的概率就是说一个人和一个吸血鬼相遇,且人成功变成吸血鬼的概率为(n-i Read More
posted @ 2011-10-30 15:19 Because Of You Views(635) Comments(5) Diggs(0) Edit
强大的题目分类 Read More
posted @ 2011-10-30 14:57 Because Of You Views(148) Comments(0) Diggs(0) Edit
开始的时候二分的地方写错了,一直找不出错,搜搜别人的题解,一对比就知道了每次输入的是一对点,只能在其中选一个点画圆,然后二分枚举半径,把不矛盾的点连一条边,建好图后,判断强连通是否有解即可,即会不会有某一对点属于同一个强连通分量中,如果都不会,则半径合法View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<vector> 4 #include<math.h> 5 #include<algorithm> 6 using namespace std; 7 const i Read More
posted @ 2011-10-29 20:48 Because Of You Views(382) Comments(0) Diggs(0) Edit
感觉建图复杂度过大啊,但还是AC了。。。View Code 1 #include<stdio.h> 2 #include<string.h> 3 char str[210][1010]; 4 int map[210][210]; 5 int min(int a,int b){return a<b?a:b;} 6 const int inf = 9999999; 7 int n,match[210]; 8 bool sx[210],sy[210]; 9 int lx[210],ly[210]; 10 bool path(int u) 11 { 12 sx[u]=tr Read More
posted @ 2011-10-28 20:18 Because Of You Views(286) Comments(0) Diggs(0) Edit
比如第i个学生是 【a b】那就从i向a至b连边左边是学生,右边是排名二分匹配即可View Code 1 #include<stdio.h> 2 #include<string.h> 3 int map[62][100001]; 4 int match[100010]; 5 bool vis[100010]; 6 int mi,mx; 7 bool dfs(int u) 8 { 9 int i;10 for(i=mi;i<=mx;i++)11 {12 if(map[u][i]&&!vis[i])13 {14 vi... Read More
posted @ 2011-10-28 18:50 Because Of You Views(292) Comments(0) Diggs(0) Edit
上一页 1 ··· 28 29 30 31 32 33 34 35 36 ··· 42 下一页