- 注册时间
- 2007-4-13
- 最后登录
- 1970-1-1
|

楼主 |
发表于 2009-6-3 22:32:21
|
显示全部楼层
原帖由 绿鸟 于 2009-6-3 11:02 发表 
貌似题目少了什么东西的说,我因此一直不解,题设当中没给出具体i,j位置上初始的萝卜数目吧,难道最后也要我们用公式表达吗?难道萝卜数目 = field[j]?
都是用的字母代替感觉就怪怪的说…… ...
我只是截张图 让大家观赏一下
没有让大家看题的意思
题很白痴的
满分250分(时间分,两题总共1个小时限时,不判正误,接题直接提交就是满分)
代码分4号公布
C++完整原题如下:
Problem Statement
话说你在走路上班时,经过一片种植萝卜的农田。这块田地的形状是一个矩形的网格。field的第i个元素的第j个字符,表示田地的第i行第j列的格子里包含的萝卜的数目。我们定义一个格子的特殊程度为它周围所有格子的萝卜个数的和; 它周围的格子包含它上下左右以及对角相邻的格子,最多有8个,在田地的边界上的格子会少一些。如果一个格子周围没有别的格子,则它的特殊程度为0。
请返回田地中特殊程度在A和B之间的所有格子的数目(包含A,B)。
Definition
Class:
NumberField
Method:
countSpecialNumbers
Parameters:
vector <string>, int, int
Returns:
int
Method signature:
int countSpecialNumbers(vector <string> field, int A, int B)
(be sure your method is public)
Constraints
-
field 包含1个到50个元素,含1和50。
-
field的每个元素包含1个到50个字符,含1和50。
-
field的每个元素包含相同的字符数。
-
field的每个元素的字符均为’0’到’9’之一。
-
A的范围会在0到100之间,含0和100。
-
B 的范围会在A到100之间,含A和100。
Examples
0)
{"111",
"111",
"111"}
4
8
Returns: 5
在这块田地里面,位于角落的格子的特殊程度是3,位于中间的格子的特殊程度是8,其他4个格子的特殊程度为5。
1)
{"111",
"141",
"111"}
4
8
Returns: 9
现在所有的9个格子都满足要求。
2)
{"2309",
"0239",
"2314"}
5
7
Returns: 3
3)
{"924",
"231",
"390",
"910",
"121"}
31
36
Returns: 0
4)
{"5"}
3
8
Returns: 0
5)
{"1234567890",
"1234567890",
"1234567890",
"1234567890",
"1234567890",
"1234567890",
"1234567890",
"1234567890",
"1234567890",
"1234567890",
"1234567890"}
3
18
Returns: 26
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.
JAVA版的定义部分
Definition
Class:
NumberField
Method:
countSpecialNumbers
Parameters:
String[], int, int
Returns:
int
Method signature:
int countSpecialNumbers(String[] field, int A, int B)
(be sure your method is public)
[ 本帖最后由 xelz 于 2009-6-3 22:37 编辑 ] |
|