摘要: 1 #include<stdio.h> 2 #include<string.h> 3 #include<algorithm> 4 using namespace std; 5 #define maxn 1005 6 int fa[maxn],degree[maxn]; 7 8 int findfather(int x) 9 {10 if(fa[x]!=x)11 fa[x]=findfather(fa[x]);12 return fa[x];13 }14 void init(int n)15 {16 int i;17 memset(degree... 阅读全文
posted @ 2012-11-02 16:24 M_cag 阅读(600) 评论(0) 推荐(0)
摘要: Curling 2.0Time Limit: 1000MSMemory Limit: 65536KTotal Submissions: 7356Accepted: 3069DescriptionOn Planet MM-21, after their Olympic games this year, curling is getting popular. But the rules are somewhat different from ours. The game is played on an ice game board on which a square mesh is marked. 阅读全文
posted @ 2012-10-29 19:46 M_cag 阅读(188) 评论(0) 推荐(0)
摘要: A Knight's JourneyTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 22306Accepted: 7546DescriptionBackground The knight is getting bored of seeing the same black and white squares again and again and has decided to make a journey around the world. Whenever a knight moves, it is two square 阅读全文
posted @ 2012-10-28 20:46 M_cag 阅读(230) 评论(0) 推荐(0)
摘要: 连连看Time Limit: 20000/10000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 10550Accepted Submission(s): 2805Problem Description“连连看”相信很多人都玩过。没玩过也没关系,下面我给大家介绍一下游戏规则:在一个棋盘中,放了很多的棋子。如果某两个相同的棋子,可以通过一条线连起来(这条线不能经过其它棋子),而且线的转折次数不超过两次,那么这两个棋子就可以在棋盘上消去。不好意思,由于我以前没有玩过连连看,咨询了同学的意 阅读全文
posted @ 2012-10-17 21:08 M_cag 阅读(342) 评论(0) 推荐(0)
摘要: Max SumTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 87019Accepted Submission(s): 20165Problem DescriptionGiven a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the... 阅读全文
posted @ 2012-10-14 21:31 M_cag 阅读(174) 评论(0) 推荐(0)
摘要: #include<stdio.h>#include<math.h>#define PI 3.1415926535898#define e 2.7182818284590 int main(){int t,n;double ans;scanf("%d",&t);while(t--){scanf("%d",&n);ans=log10(sqrt(2*PI*n))+n*log10(n/e);printf("%.0lf\n",ceil(ans));}return 0;} 阅读全文
posted @ 2012-10-09 21:09 M_cag 阅读(96) 评论(0) 推荐(0)
摘要: 变形课Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 131072/65536 K (Java/Others)Total Submission(s): 7187Accepted Submission(s): 2673Problem Description呃......变形课上Harry碰到了一点小麻烦,因为他并不像Hermione那样能够记住所有的咒语而随意的将一个棒球变成刺猬什么的,但是他发现了变形咒语的一个统一规律:如果咒语是以a开头b结尾的一个单词,那么它的作用就恰好是使A物体变成B物体. Harry已经将他所会的所有咒语都列成了一 阅读全文
posted @ 2012-09-25 20:23 M_cag 阅读(146) 评论(0) 推荐(0)
摘要: 一道很水的题,我把它用线段树来写的,算是一看点吧#include<stdio.h>#define maxn 105double sum[maxn<<2];double max(double a,double b){ if(a>b) return a; else return b;}void btree(int l,int r,int rt){ if(l==r) { scanf("%lf",&sum[rt]); return; } int mid=(l+r)>>1; btree(l,mid... 阅读全文
posted @ 2012-09-24 20:10 M_cag 阅读(151) 评论(0) 推荐(0)
摘要: A Simple Problem with IntegersTime Limit: 5000MSMemory Limit: 131072KTotal Submissions: 36129Accepted: 10381Case Time Limit: 2000MSDescriptionYou have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a .. 阅读全文
posted @ 2012-09-14 20:40 M_cag 阅读(350) 评论(0) 推荐(0)
摘要: Just a HookTime Limit: 4000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9758Accepted Submission(s): 4776Problem DescriptionIn the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecut 阅读全文
posted @ 2012-09-14 09:23 M_cag 阅读(754) 评论(0) 推荐(0)