摘要: DescriptionGiven an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th column. Initially we have A[i, j] = 0 (1 <= i, j <= N). We can change the matrix in the following way. Given a rectangle whose upper-left corner is (x1, y1) and lower-right cor 阅读全文
posted @ 2012-03-27 17:20 'wind 阅读(317) 评论(0) 推荐(0) 编辑
摘要: Description司令部的将军们打算在N*M的网格地图上部署他们的炮兵部队。一个N*M的地图由N行M列组成,地图的每一格可能是山地(用"H" 表示),也可能是平原(用"P"表示),如下图。在每一格平原地形上最多可以布置一支炮兵部队(山地上不能够部署炮兵部队);一支炮兵部队在地图上的攻击范围如图中黑色区域所示: 如果在地图中的灰色所标识的平原上部署一支炮兵部队,则图中的黑色的网格表示它能够攻击到的区域:沿横向左右各两格,沿纵向上下各两格。图上其它白色网格均攻击不到。从图上可见炮兵的攻击范围不受地形的影响。 现在,将军们规划如何部署炮兵部队,在防止误伤的 阅读全文
posted @ 2012-03-25 21:53 'wind 阅读(244) 评论(0) 推荐(0) 编辑
摘要: DescriptionThe most exciting space discovery occurred at the end of the 20th century. In 1999, scientists traced down an ant-like creature in the planet Y1999 and called it M11. It has only one eye on the left side of its head and just three feet all on the right side of its body and suffers from th 阅读全文
posted @ 2012-03-24 23:56 'wind 阅读(236) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionHogwarts正式开学以后,Harry发现在Hogwarts里,某些楼梯并不是静止不动的,相反,他们每隔一分钟就变动一次方向. 比如下面的例子里,一开始楼梯在竖直方向,一分钟以后它移动到了水平方向,再过一分钟它又回到了竖直方向.Harry发现对他来说很难找到能使得他最快到达目的地的路线,这时Ron(Harry最好的朋友)告诉Harry正好有一个魔法道具可以帮助他寻找这样的路线,而那个魔法道具上的咒语,正是由你纂写的.Input测试数据有多组,每组的表述如下:第一行有两个数,M和N,接下来是一个M行N列的地图,'*'表示障碍物,'. 阅读全文
posted @ 2012-03-24 17:04 'wind 阅读(256) 评论(0) 推荐(0) 编辑
摘要: Problem Description在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。Input输入含有多组测试数据。 每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目。 n <= 8 , k <= n 当为-1 -1时表示输入结束。 随后的n行描述了棋盘的形状:每行有n个字符,其中 # 表示棋盘区域, . 表示空白区域(数据保证不出现多余的空白行或者空白列)。Outpu 阅读全文
posted @ 2012-03-24 14:05 'wind 阅读(217) 评论(0) 推荐(0) 编辑
摘要: DescriptionA university network is composed of N computers. System administrators gathered information on the traffic between nodes, and carefully divided the network into two subnetworks in order to minimize traffic between parts. A disgruntled computer science student Vasya, after being expelled f 阅读全文
posted @ 2012-03-23 18:58 'wind 阅读(170) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionFor a boat on a large body of water, strong currents can be dangerous, but with careful planning, they can be harnessed to help the boat reach its destination. Your job is to help in that planning.At each location, the current flows in some direction. The captain can choose to eit 阅读全文
posted @ 2012-03-23 13:09 'wind 阅读(233) 评论(0) 推荐(0) 编辑
摘要: DescriptionYou are given two pots, having the volume of A and B liters respectively. The following operations can be performed:FILL(i) fill the pot i (1 ≤ i ≤ 2) from the tap;DROP(i) empty the pot ito the drain;POUR(i,j) pour from pot i to pot j; after this operation either the pot j is full (and th 阅读全文
posted @ 2012-03-22 19:27 'wind 阅读(205) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionACboy很喜欢玩一种战略游戏,在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中ACboy允许攻克M个城堡并获得里面的宝物。但由于地理位置原因,有些城堡不能直接攻克,要攻克这些城堡必须先攻克其他某一个特定的城堡。你能帮ACboy算出要获得尽量多的宝物应该攻克哪M个城堡吗?Input每个测试实例首先包括2个整数,N,M.(1 <= M <= N <= 200);在接下来的N行里,每行包括2个整数,a,b. 在第 i 行,a 代表要攻克第 i 个城堡必须先攻克第 a 个城堡,如果 a = 0 则代表可以直接攻克第 i 个城堡。b 阅读全文
posted @ 2012-03-22 17:44 'wind 阅读(306) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionThere is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees. It means that the supervisor relation forms a tree rooted at the rector V. E. Tretyakov. In order to make the party funny for eve 阅读全文
posted @ 2012-03-22 00:10 'wind 阅读(376) 评论(0) 推荐(0) 编辑
摘要: DescriptionYou are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one unit north, south, east, west, up or down. You cannot move diagonally and the maze is surrounded by solid 阅读全文
posted @ 2012-03-21 20:39 'wind 阅读(178) 评论(0) 推荐(0) 编辑
摘要: DescriptionThe cornfield maze is a popular Halloween treat. Visitors are shown the entrance and must wander through the maze facing zombies, chainsaw-wielding psychopaths, hippies, and other terrors on their quest to find the exit. One popular maze-walking strategy guarantees that the visitor will e 阅读全文
posted @ 2012-03-20 21:01 'wind 阅读(190) 评论(0) 推荐(0) 编辑
摘要: Description今年是国际数学联盟确定的“2000——世界数学年”,又恰逢我国著名数学家华罗庚先生诞辰90周年。在华罗庚先生的家乡江苏金坛,组织了一场别开生面的数学智力竞赛的活动,你的一个好朋友XZ也有幸得以参加。活动中,主持人给所有参加活动的选手出了这样一道题目:设有一个长度为N的数字串,要求选手使用K个乘号将它分成K+1个部分,找出一种分法,使得这K+1个部分的乘积能够为最大。同时,为了帮助选手能够正确理解题意,主持人还举了如下的一个例子:有一个数字串:312, 当N=3,K=1时会有以下两种分法:1) 3*12=362) 31*2=62 这时,符合题目要求的结果是:31*2=62现 阅读全文
posted @ 2012-03-19 23:27 'wind 阅读(306) 评论(0) 推荐(0) 编辑
摘要: Description传说中的火之国一年一度的公务员选拔又开始了!木叶忍者村此次也要从中选拔出5人来,作为即将上任的新火影纲手的小弟~,可是报考公务员的人数实在是太~~多啦!所以纲手的贴身随从—静音小姐,决定对这写人进行分m批的选拔,每次笔试n人,第一次选出5人,之后每次从这n人与之前参加笔试但未选中的人一起再选出分数最高的5人,这样下来可以刷掉一大批人,但纲手只需要5人,这时候就轮到静音小姐的跟班小弟--卡卡西,来将这些人再进行二次筛选,卡卡西决定对这些人进行忍术测试,然后选出前5名,作为最后选出的人选,如果忍术分数相同,那么名字字典序靠前的被选中。Input首先是整数m和n,表示要进行m波 阅读全文
posted @ 2012-03-19 20:46 'wind 阅读(508) 评论(0) 推荐(0) 编辑
摘要: DescriptionThe citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whim. The city council has finally decided to build an electoral wall for placing the posters and introduce the following rul 阅读全文
posted @ 2012-03-19 16:46 'wind 阅读(172) 评论(0) 推荐(0) 编辑
摘要: Description因为大蛇丸的捣乱,木叶忍者村痛失了和蔼的三代火影,所以身为三代火影徒弟之一的纲手不得不接受木叶村火影的职务~,因为刚刚上任,所以纲手大人需要对木叶村主要忍者的实力有个了解,以方便以后分配任务,所以我们需要统计一下每个忍者的实力高低,作为刚刚通过公务员选拔的你,这可是个很好的表现机会~你需要做的是将所有给定忍者部分实力高低关系,然后在需要的时候能够快速的查找到.Input给出一个整数n,然后n行每行给出两个名字,表示前一个忍者强于后一个,然后是一个整数m,表示m个查找,然后是m行,每行也是两个名字。输入到文件尾。忍者的个数在1000以内,名字不长于20,n<10000 阅读全文
posted @ 2012-03-18 19:02 'wind 阅读(11962) 评论(0) 推荐(0) 编辑
摘要: View Code #include<stdio.h>#include<string.h>#include<stdlib.h>struct node{ int speed; int weight; int id;}q[1001];int cmp(const void*p1,const void*p2){ struct node*c=(struct node*)p1; struct node*d=(struct node*)p2; if(c->weight==d->weight) return d->speed-c->speed; re 阅读全文
posted @ 2012-03-18 10:09 'wind 阅读(334) 评论(0) 推荐(0) 编辑
摘要: DescriptionYour task in this problem is to determine the number of divisors of Cnk. Just for fun -- or do you need any special reason for such a useful computation?InputThe input consists of several instances. Each instance consists of a single line containing two integers n and k (0 ≤ k ≤ n ≤ 431), 阅读全文
posted @ 2012-03-17 19:03 'wind 阅读(213) 评论(0) 推荐(0) 编辑
摘要: DescriptionIt is well known that a human gene can be considered as a sequence, consisting of four nucleotides, which are simply denoted by four letters, A, C, G, and T. Biologists have been interested in identifying human genes and determining their functions, because these can be used to diagnose h 阅读全文
posted @ 2012-03-16 21:02 'wind 阅读(294) 评论(0) 推荐(0) 编辑
摘要: Problem Description有三个正整数a,b,c(0<a,b,c<10^6),其中c不等于b。若a和c的最大公约数为b,现已知a和b,求满足条件的最小的c。Input第一行输入一个n,表示有n组测试数据,接下来的n行,每行输入两个正整数a,b。Output输出对应的c,每组测试数据占一行。Sample Input26 212 4Sample Output4code:View Code #include<stdio.h> int gcd( int x ,int y) { if(y==0) return x; retu... 阅读全文
posted @ 2012-03-16 17:18 'wind 阅读(149) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionEddy是个ACMer,他不仅喜欢做ACM题,而且对于纸牌也有一定的研究,他在无聊时研究发现,如果他有2N张牌,编号为1,2,3..n,n+1,..2n。这也是最初的牌的顺序。通过一次洗牌可以把牌的序列变为n+1,1,n+2,2,n+3,3,n+4,4..2n,n。那么可以证明,对于任意自然数N,都可以在经过M次洗牌后第一次重新得到初始的顺序。编程对于小于100000的自然数N,求出M的值。Input每行一个整数NOutput输出与之对应的MSample Input201Sample Output202洗牌问题:定理1:当第一张牌(牌1)回到初始位置时,所 阅读全文
posted @ 2012-03-16 17:16 'wind 阅读(538) 评论(0) 推荐(0) 编辑
摘要: DescriptionPythagorean Theorem is "humanity's greatest scientific discoveries of the ten" is a basic elementary geometry theorems."This theorem has a very long history, almost all ancient civilizations (Greece, China, Egypt, Babylon, India, etc.) have studied this theorem. Pythago 阅读全文
posted @ 2012-03-16 17:13 'wind 阅读(413) 评论(0) 推荐(0) 编辑
摘要: Problem Description反素数就是满足对于任意i(0<i<x),都有g(i)<g(x),(g(x)是x的因子个数),则x为一个反素数。现在给你一个整数区间[a,b],请你求出该区间的x使g(x)最大。Input第一行输入n,接下来n行测试数据输入包括a,b, 1<=a<=b<=5000,表示闭区间[a,b].Output输出为一个整数,为该区间因子最多的数.如果满足条件有多个,则输出其中最小的数.Sample Input32 31 1047 359Sample Output26240分析:打表。code:View Code #include&l 阅读全文
posted @ 2012-03-16 17:12 'wind 阅读(471) 评论(0) 推荐(0) 编辑
摘要: Problem Description一日,话说0068与***泛舟湖上。忽见岸边出现他的一大敌人elnil。0068当然不想落入elnil的魔爪,于是他就得想办法逃脱。这个湖是一个很规则的圆形,半径为R。此时0068正好在圆心位置。小船在湖中的速度为 V1,0068和elnil在岸上的速度都为V2。也就是说,如果0068在刚上岸的时候没被抓到,则他可逃脱。在任意时刻,0068和elnil都可以朝任何方向移动,但是0068不能一直呆上船上(会饿死的),elnil不能下水(他不会游泳)。假设0068和elnil都非常聪明,总能做对自己最有利的事情,而且两个人的体力都是无限的。请问,0068最终能 阅读全文
posted @ 2012-03-16 17:11 'wind 阅读(143) 评论(0) 推荐(0) 编辑
摘要: Description给出N个数(保证N为偶数),其中有且只有两个不同的数字出现了奇数次。请你找出他们来。Input对于每组测试数据:第一行,给出数字N,表示下一行输入N个数字,其中N为偶数(2<=N<=100000)第二行,有N个数字(每个数字保证可以使用INT表示)处理到文件结束Output对于每组测试数据:第一行,输出找到的两个数字,由小到大。Sample Input41 2 3 3Sample Output1 2分析: 第一次读入得到a^b; 第二次读入时根据a^b为1的位来把数据分为该位为1和0的两组,然后再分别异或得到a,b;code:View Code #includ 阅读全文
posted @ 2012-03-16 17:10 'wind 阅读(149) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionDilworth is the world’s most prominent collector of Russian nested dolls: he literally has thousands of them! You know, the wooden hollow dolls of different sizes of which the smallest doll is contained in the second smallest, and this doll is in turn contained in the next one and 阅读全文
posted @ 2012-03-16 17:08 'wind 阅读(190) 评论(0) 推荐(0) 编辑
摘要: DescriptionAssume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation, locating on the coasting, can only cover d distance, so an island in the sea can be covered by a radius i 阅读全文
posted @ 2012-03-16 17:07 'wind 阅读(147) 评论(0) 推荐(0) 编辑
摘要: Problem Description“今年暑假不AC?”“是的。”“那你干什么呢?”“看世界杯呀,笨蛋!”“@#$%^&*%...”确实如此,世界杯来了,球迷的节日也来了,估计很多ACMer也会抛开电脑,奔向电视了。作为球迷,一定想看尽量多的完整的比赛,当然,作为新时代的好青年,你一定还会看一些其它的节目,比如新闻联播(永远不要忘记关心国家大事)、非常6+7、超级女生,以及王小丫的《开心辞典》等等,假设你已经知道了所有你喜欢看的电视节目的转播时间表,你会合理安排吗?(目标是能看尽量多的完整节目)Input输入数据包含多个测试实例,每个测试实例的第一行只有一个整数n(n<=100 阅读全文
posted @ 2012-03-16 17:06 'wind 阅读(418) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionHere is a famous story in Chinese history."That was about 2300 years ago. General Tian Ji was a high official in the country Qi. He likes to play horse racing with the king and others.""Both of Tian and the king have three horses in different classes, namely, regula 阅读全文
posted @ 2012-03-16 17:05 'wind 阅读(237) 评论(0) 推荐(0) 编辑
摘要: Description前段时间,某省发生干旱,B山区的居民缺乏生活用水,现在需要从A城市修一条通往B山区的路。假设有A城市通往B山区的路由m条连续的路段组成,现在将这m条路段承包给n个工程队(n≤m≤ 300)。为了修路的便利,每个工程队只能分配到连续的若干条路段(当然也可能只分配到一条路段或未分配到路段)。假设每个工程队修路的效率一样,即每修长度为1的路段所需的时间为1。现在给出路段的数量m,工程队的数量n,以及m条路段的长度(这m条路段的长度是按照从A城市往B山区的方向依次给出,每条路段的长度均小于1000),需要你计算出修完整条路所需的最短的时间(即耗时最长的工程队所用的时间)。Inpu 阅读全文
posted @ 2012-03-16 17:04 'wind 阅读(204) 评论(0) 推荐(0) 编辑