注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

因心造境 风云由我

丈夫生时会几时,安能蹀躞垂羽翼

 
 
 

日志

 
 

[转]Google中国编程挑战赛  

2008-03-04 12:51:38|  分类: 职场竞技 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

[转]Google中国编程挑战赛    [转]Google中国编程挑战赛 - ☆晴心星雨☆ - 因心造境 风云由我[转]Google中国编程挑战赛 - ☆晴心星雨☆ - 因心造境 风云由我[转]Google中国编程挑战赛 - ☆晴心星雨☆ - 因心造境 风云由我[转]Google中国编程挑战赛 - ☆晴心星雨☆ - 因心造境 风云由我  引用 俄罗斯美少女 - bfgxwzb - 怀若的博客

今天准备参加google中国编程挑战赛,才发现原来自己好久没写过程序了。在训练场的时候,就感觉到有点不知所措了,就连最基本的String的用法都有些让我无所适从了,郁闷,真是眼高手低呀,看别人的代码的时候总感觉不到什么难度,真到自己写真就捉襟见肘了。

晚上和小侯一起上去参加预选赛,结果就不出意外的受打击了,我在65分钟的时候完整的作出来了两道题目中的一个(还是250分的,750分的那个没来得及看)。不幸的是,考试时间是一个小时,也就是说我交上去的是个不怎么正确的,得到的是可怜的90来分。这是我所在组的排行榜,强人真是多的很哪!!

[转]Google中国编程挑战赛 - ☆晴心星雨☆ - 因心造境 风云由我

受打击了,整天喊着好好学习天天向上,也不知道自己到底学到了什么,真是对不起毛主席他老人家。贴出我做的那一题目,仅作立此存照意。

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. (c)2003, TopCoder, Inc. All rights reserved.

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=552977

  评论这张
 
阅读(88)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017