摘要: DescriptionYou are given a bunch of wooden sticks. Each endpoint of each stick is colored with some color. Is it possible to align the sticks in a straight line such that the colors of the endpoints that touch are of the same color?InputInput is a sequence of lines, each line contains two words, sep 阅读全文
posted @ 2012-03-16 00:37 'wind 阅读(206) 评论(0) 推荐(0) 编辑
摘要: Problem Description呃......变形课上Harry碰到了一点小麻烦,因为他并不像Hermione那样能够记住所有的咒语而随意的将一个棒球变成刺猬什么的,但是他发现了变形咒语的一个统一规律:如果咒语是以a开头b结尾的一个单词,那么它的作用就恰好是使A物体变成B物体.Harry已经将他所会的所有咒语都列成了一个表,他想让你帮忙计算一下他是否能完成老师的作业,将一个B(ball)变成一个M(Mouse),你知道,如果他自己不能完成的话,他就只好向Hermione请教,并且被迫听一大堆好好学习的道理.Input测试数据有多组。每组有多行,每行一个单词,仅包括小写字母,是Harry所 阅读全文
posted @ 2012-03-16 00:36 'wind 阅读(137) 评论(0) 推荐(0) 编辑
摘要: Problem Description欧拉回路是指不令笔离开纸面,可画过图中每条边仅一次,且可以回到起点的一条回路。现给定一个图,问是否存在欧拉回路?Input测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是节点数N ( 1 < N < 1000 )和边数M;随后的M行对应M条边,每行给出一对正整数,分别是该条边直接连通的两个节点的编号(节点从1到N编号)。当N为0时输入结束。Output每个测试用例的输出占一行,若欧拉回路存在则输出1,否则输出0。Sample Input3 31 21 32 33 21 22 30Sample Output10总结:如果图是联 阅读全文
posted @ 2012-03-16 00:34 'wind 阅读(236) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionSome of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Because there is no other way to open the doors, the puzzle is very important for us.There is a large number of magnetic plates on every door. Every plat 阅读全文
posted @ 2012-03-16 00:34 'wind 阅读(290) 评论(0) 推荐(0) 编辑
摘要: Problem Description在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt。但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要寻找最短的从商店到赛场的路线,你可以帮助他们吗?Input输入包括多组数据。每组数据第一行是两个整数N、M(N<=100,M<=10000),N表示成都的大街上有几个路口,标号为1的路口是商店所在地,标号为N的路口是赛场所在地,M则表示在成都有几条路。N=M=0表示输入结束。接下来M行,每行包括3个整数A,B,C(1<=A,B<=N,1<=C<=1000),表示在 阅读全文
posted @ 2012-03-16 00:33 'wind 阅读(180) 评论(0) 推荐(0) 编辑
摘要: DescriptionAdvanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The company has its own code describing each type of a truck. The code is simply a string of exactly seven lowercase letters (each letter on each 阅读全文
posted @ 2012-03-16 00:31 'wind 阅读(153) 评论(0) 推荐(0) 编辑
摘要: Description东北的冬季,尤其是过年的时候,小陈老师喜欢去堆雪人。每个雪人主要由三个雪球构成:大雪球、中雪球、小雪球。他已经准备好了N个雪球,半径分别等于r1, r2, ..., rn。如果要堆一个雪人,就需要三个半径互不相等的雪球。例如:三个雪球的半径为1、2、3,能够用来堆一个雪人。但是半径为2、2、3或者2、2、2的三个雪球就不可以。快帮帮小陈老师,算算他最多能用这些雪球堆多少个雪人。Input对于每组测试数据:第1行,包含一个整数n(1≤n≤100000) — 雪球的数量。第2行,包含n个整数 — 雪球的半径r1, r2, ..., rn (1≤ri≤1000000000)。处 阅读全文
posted @ 2012-03-16 00:29 'wind 阅读(268) 评论(0) 推荐(0) 编辑
摘要: DescriptionBessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she wants to get back as quickly as possible.Farmer John's field has N (2 <= N <= 1000) landmarks 阅读全文
posted @ 2012-03-15 23:31 'wind 阅读(194) 评论(0) 推荐(0) 编辑
摘要: DescriptionN(1 ≤N≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code better than others. Each cow has a certain constant skill rating that is unique among the competitors.The contest is conducted in several head-to-head rounds, each bet 阅读全文
posted @ 2012-03-15 23:29 'wind 阅读(270) 评论(0) 推荐(0) 编辑
摘要: Problem Description有N个比赛队(1<=N<=500),编号依次为1,2,3,。。。。,N进行比赛,比赛结束后,裁判委员会要将所有参赛队伍从前往后依次排名,但现在裁判委员会不能直接获得每个队的比赛成绩,只知道每场比赛的结果,即P1赢P2,用P1,P2表示,排名时P1在P2之前。现在请你编程序确定排名。Input输入有若干组,每组中的第一行为二个数N(1<=N<=500),M;其中N表示队伍的个数,M表示接着有M行的输入数据。接下来的M行数据中,每行也有两个整数P1,P2表示即P1队赢了P2队。Output给出一个符合要求的排名。输出时队伍号之间有空格, 阅读全文
posted @ 2012-03-15 23:28 'wind 阅读(202) 评论(0) 推荐(0) 编辑
摘要: Problem Description某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。Input本题目包含多组数据,请处理到文件结束。每组数据第一行包含两个正整数N和M(0<N<200,0<M<1000),分别代表现有城镇的数目和已修建的道路的数目。城镇分别以0~N-1编号。接下来是M行道路信息。每一行有三个整数A,B,X(0<=A,B<N,A! 阅读全文
posted @ 2012-03-15 23:27 'wind 阅读(186) 评论(0) 推荐(0) 编辑
摘要: Problem Description相信大家都听说一个“百岛湖”的地方吧,百岛湖的居民生活在不同的小岛中,当他们想去其他的小岛时都要通过划小船来实现。现在政府决定大力发展百岛湖,发展首先要解决的问题当然是交通问题,政府决定实现百岛湖的全畅通!经过考察小组RPRush对百岛湖的情况充分了解后,决定在符合条件的小岛间建上桥,所谓符合条件,就是2个小岛之间的距离不能小于10米,也不能大于1000米。当然,为了节省资金,只要求实现任意2个小岛之间有路通即可。其中桥的价格为 100元/米。Input输入包括多组数据。输入首先包括一个整数T(T <= 200),代表有T组数据。每组数据首先是一个整 阅读全文
posted @ 2012-03-15 23:26 'wind 阅读(159) 评论(0) 推荐(0) 编辑
摘要: DescriptionIn some cultural traditions, giving chocolate as a present on Valentine’s Day is a very traditional symbol of love. LDA does some research on chocolate manufacturing. And luckily, he makes some good quality chocolate bars. In addition, these chocolate bars are very long. They are composed 阅读全文
posted @ 2012-03-15 23:24 'wind 阅读(167) 评论(0) 推荐(0) 编辑
摘要: Description既然大家都不愿意做水题,元帅也很无奈,想了好久也不知道什么是水题,因为在元帅的眼里都是水题,他定义的非水题就是他做不出来的题。太囧了,随便弄个水的MST。Input测试输入包含若干测试用例。每个测试用例的第1行给出顶点数目N ( < 100 );随后的N(N-1)/2行对应村庄间的距离,每行给出一对正整数,分别是两个顶点的编号,以及此两村庄间的距离。为简单起见,村庄从1到N编号。当N为0时,输入结束,该用例不被处理。Output对于每个测试用例,输出MST的最小路径总长度。Sample Input31 2 11 3 22 3 441 2 11 3 41 4 12 3 阅读全文
posted @ 2012-03-15 23:21 'wind 阅读(180) 评论(0) 推荐(0) 编辑
摘要: DescriptionYou 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 given interval. The other is to ask for the sum of numbers in a given interval.InputThe first line contains two numbers N and Q. 1 ≤ 阅读全文
posted @ 2012-03-15 22:06 'wind 阅读(167) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionThe famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure. The floor has 200 rooms each on the north side and south side along the corridor. Recently the Company made a plan to reform its system. The reform includes mo 阅读全文
posted @ 2012-03-15 19:03 'wind 阅读(188) 评论(0) 推荐(0) 编辑
摘要: A path with no repeated vertices of an undirected graph is called a simple path. Given an undirected graph and two verteices S and D, return the number of vertics which don't lie on any simple paths between S and D.InputThe input contains multiple test cases.Each case starts with a line of four 阅读全文
posted @ 2012-03-15 13:01 'wind 阅读(297) 评论(0) 推荐(0) 编辑
摘要: Problem Description蜘蛛牌是windows xp操作系统自带的一款纸牌游戏,游戏规则是这样的:只能将牌拖到比她大一的牌上面(A最小,K最大),如果拖动的牌上有按顺序排好的牌时,那么这些牌也跟着一起移动,游戏的目的是将所有的牌按同一花色从小到大排好,为了简单起见,我们的游戏只有同一花色的10张牌,从A到10,且随机的在一行上展开,编号从1到10,把第i号上的牌移到第j号牌上,移动距离为abs(i-j),现在你要做的是求出完成游戏的最小移动距离。Input第一个输入数据是T,表示数据的组数。每组数据有一行,10个输入数据,数据的范围是[1,10],分别表示A到10,我们保证每组数 阅读全文
posted @ 2012-03-15 13:00 'wind 阅读(351) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionThere is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N) on every floor.The lift have just two buttons: up and down.When you at floor i,if you press the button "UP" , you will go up Ki floor,i.e,you will go to 阅读全文
posted @ 2012-03-15 13:00 'wind 阅读(175) 评论(0) 推荐(0) 编辑
摘要: Description机器人要在一个矩形迷宫里行动(不能原地停留,只能走向上/下/左/右),每移动一格花费1个单位时间。迷宫有以下几种元素:【*】机器人的起点【#】墙。机器人不能走过这些格子【.】平地。机器人可以在上面自由行走【0-9】宝藏。当机器人走到此处会立刻获得该数字相应的宝藏,宝藏不会消失,可以反复获取(但不能停留)若机器人要恰好获得总和为x的宝藏,它最少需要多少时间?Input第一行输入任务数量T,接下来有T个任务每块第一行有两个整数, n(0 <100), m(0 < 100),表示迷宫有n+1行和m+1列接下来n行输入迷宫最后一行输入你要收集的宝藏的总价值x(x≤10 阅读全文
posted @ 2012-03-15 12:59 'wind 阅读(224) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionSuppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street or a piece of wall. A blockhouse is a small castle that has four openings through which to shoot. The four openings are facing North, E 阅读全文
posted @ 2012-03-15 12:58 'wind 阅读(168) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionThere is a mountain near yifenfei’s hometown. On the mountain lived a big monster. As a hero in hometown, yifenfei wants to kill it.Now we know yifenfei have n spells, and the monster have m HP, when HP <= 0 meaning monster be killed. Yifenfei’s spells have different effect if 阅读全文
posted @ 2012-03-15 12:57 'wind 阅读(260) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionYou're in space.You want to get home. There are asteroids. You don't want to hit them. InputInput to this problem will consist of a (non-empty) series of up to 100 data sets. Each data set will be formatted according to the following description, and there will be no blank 阅读全文
posted @ 2012-03-15 12:56 'wind 阅读(214) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionZty is a man that always full of enthusiasm. He wants to solve every kind of difficulty ACM problem in the world. And he has a habit that he does not like to solvea problem that is easy than problem he had solved. Now yifenfei give him n difficulty problems, and tell him their rel 阅读全文
posted @ 2012-03-15 12:55 'wind 阅读(214) 评论(0) 推荐(0) 编辑
摘要: Problem Description在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。你的任务是,对于给定的N,求出有多少种合法的放置方法。Input共有若干行,每行一个正整数N≤10,表示棋盘和皇后的数量;如果N=0,表示结束。Output共有若干行,每行一个正整数,表示对应输入行的皇后的不同放置数量。Sample Input1850Sample Output19210code :View Code #include<stdio.h>#include<string.h>int tot 阅读全文
posted @ 2012-03-15 12:54 'wind 阅读(191) 评论(0) 推荐(0) 编辑
摘要: Problem Description呃......变形课上Harry碰到了一点小麻烦,因为他并不像Hermione那样能够记住所有的咒语而随意的将一个棒球变成刺猬什么的,但是他发现了变形咒语的一个统一规律:如果咒语是以a开头b结尾的一个单词,那么它的作用就恰好是使A物体变成B物体.Harry已经将他所会的所有咒语都列成了一个表,他想让你帮忙计算一下他是否能完成老师的作业,将一个B(ball)变成一个M(Mouse),你知道,如果他自己不能完成的话,他就只好向Hermione请教,并且被迫听一大堆好好学习的道理.Input测试数据有多组。每组有多行,每行一个单词,仅包括小写字母,是Harry所 阅读全文
posted @ 2012-03-15 12:53 'wind 阅读(177) 评论(0) 推荐(0) 编辑
摘要: DescriptionFlip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the other one is black and each piece is lying either it's black or white side up. Each round you flip 3 to 5 pieces, thus changing the color of t 阅读全文
posted @ 2012-03-15 12:52 'wind 阅读(266) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionAngel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, ROADs, and GUARDs in the prison.Angel's friends want to save Angel. Their task is: approach Angel. We assume that "approach Angel 阅读全文
posted @ 2012-03-15 12:51 'wind 阅读(167) 评论(0) 推荐(0) 编辑
摘要: DescriptionBackgroundMr Somurolov, fabulous chess-gamer indeed, asserts that no one else but him can move knights from one position to another so fast. Can you beat him?The ProblemYour task is to write a program to calculate the minimum number of moves needed for a knight to reach one point from ano 阅读全文
posted @ 2012-03-15 12:50 'wind 阅读(180) 评论(0) 推荐(0) 编辑
摘要: View Code #include<stdio.h>#include<string.h>int prime[40];int a[20];int vis[20];int n;int isprime(int n){ int i; for(i=2;i*i<=n;i++) if(n%i==0) return 0; return 1;}void dfs(int cur){ int i; if(cur==n&&prime[a[0]+a[n-1]]) //递归边界,最后一个数和第一个数和是质数 { for(i=0;i<n;i++... 阅读全文
posted @ 2012-03-15 12:49 'wind 阅读(131) 评论(0) 推荐(0) 编辑