Google编程大赛入围赛250分真题(转)
atomic小kitten吧
全部回复
仅看楼主
level 9
Problem Statement ???? You are given a String[] cityMap representing the layout of a city. The city consists of blocks. The first element of cityMap represents the first row of blocks, etc. A 'B' character indicates a location where there is a bus stop. There will be exactly one 'X' character, indicating your location. All other characters will be '.'. You are also given an int walkingDistance, which is the maximum distance you are willing to walk to a bus stop. The distance should be calculated as the number of blocks vertically plus the number of blocks horizontally. Return the number of bus stops that are within walking distance of your current location. Definition ???? Class: BusStops Method: countStops Parameters: String[], int Returns: int Method signature: int countStops(String[] cityMap, int walkingDistance) (be sure your method is public) ???? Constraints - cityMap will contain between 1 and 50 elements, inclusive. - Each element of cityMap will contain between 1 and 50 characters, inclusive. - Each element of cityMap will contain the same number of characters. - Each character of each element of cityMap will be 'B', 'X', or '.'. - There will be exactly one 'X' character in cityMap. - walkingDistance will be between 1 and 100, inclusive. Examples 0) ???? {"...B.", ".....", "..X.B", ".....", "B...."} 3 Returns: 2 You can reach the bus stop at the top (3 units away), or on the right (2 units away). The one in the lower left is 4 units away, which is too far. 1) ???? {"B.B..", ".....", "B....", ".....", "....X"} 8 Returns: 3 A distance of 8 can get us anywhere on the map, so we can reach all 3 bus stops. 2) ???? {"BBBBB", "BB.BB", "B.X.B", "BB.BB", "BBBBB"} 1 Returns: 0 Plenty of bus stops, but unfortunately we cannot reach any of them. 3) ???? {"B..B..", ".B...B", "..B...", "..B.X.", "B.B.B.", ".B.B.B"} 3 Returns: 7 This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. ©2003, TopCoder, Inc. All rights reserved. 
2005年12月18日 17点12分 1
level 9
应该是用随机函数或手动输入绘制一张城市地图,地图里有三种单位:B是你要在规定步数内到达的目的地;X是你所处的位置;.其实就是你要走的路,每走过一个点,步数减1。像第一个例子,你在X处,规定了要走3步,只有左边和上边的可以在3步内走到!所以返回2!其他也一样,
2005年12月18日 17点12分 2
level 9
现在也有比赛了........偶水平差N远!
2005年12月18日 17点12分 3
1