易码技术论坛

 找回密码
 加入易码
搜索
查看: 812|回复: 11

上个月的事了。谁做有道难题了?

[复制链接]
发表于 2009-6-1 20:16:23 | 显示全部楼层 |阅读模式
如题
TopCoder & 网易
《有道难题》
Untitled.jpg
Z$WK[{SSIS%N61[D[_PX[@8.jpg

[ 本帖最后由 xelz 于 2009-6-1 20:24 编辑 ]
发表于 2009-6-1 23:43:50 | 显示全部楼层
可以用vb啊
发表于 2009-6-3 10:12:13 | 显示全部楼层
楼主参加百度之星了么?
发表于 2009-6-3 11:02:08 | 显示全部楼层
貌似题目少了什么东西的说,我因此一直不解,题设当中没给出具体i,j位置上初始的萝卜数目吧,难道最后也要我们用公式表达吗?难道萝卜数目 = field[j]?
都是用的字母代替感觉就怪怪的说……
 楼主| 发表于 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 编辑 ]
 楼主| 发表于 2009-6-3 22:38:42 | 显示全部楼层
500分的题

Problem Statement
   
一个二进制序列由下面的伪代码生成:
string A = "0"
While (A的长度小于等于n)
创建一个和A一样长度的字符串B
For i=0,1,...length(A)-1
If (i 是完全平方数)
B = 1-A
Else
B = A
令A = A + B (即将B拼接在A后面)
End While
Return A
请注意,在上面的伪代码中,A和B分别表示字符串A和B中下标为i的字符(下标编号从0开始)。对“完全平方数”的定义是,对于整数i,存在整数j,使得i= j *j,则称i为完全平方数。
下面具体说明序列生成的过程:如果n=7,则在每一轮迭代中,A的取值依次为:0, 01, 0110, 01101010,所以最终产生的二进制序列就是0,1,1,0,1,0,1,0
请返回上述序列中下标为n的数字(该序列的下标从0开始)
Definition
   
Class:
BinarySequence
Method:
getValue
Parameters:
int
Returns:
int
Method signature:
int getValue(int n)
(be sure your method is public)
   

Constraints
-
n 的取值大于等于0,小于等于2,000,000,000
Examples
0)

   
7
Returns: 0
原因参见题目描述。
1)

   
2
Returns: 1

2)

   
8
Returns: 1
这一次,生成的序列为0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0.
3)

   
11
Returns: 0

4)

   
10
Returns: 1

5)

   
15
Returns: 0

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.
 楼主| 发表于 2009-6-3 22:40:15 | 显示全部楼层
原帖由 csh 于 2009-6-3 10:12 发表
楼主参加百度之星了么?



我再次承认,我是小白。。。
发表于 2009-6-5 19:49:14 | 显示全部楼层
看不懂......
 楼主| 发表于 2009-6-6 18:14:54 | 显示全部楼层
天杀的我竟然晋级了。。。。
 楼主| 发表于 2009-6-6 18:18:39 | 显示全部楼层
Untitled.jpg
发表于 2009-6-6 20:13:57 | 显示全部楼层
弱弱的问问。这是啥?
 楼主| 发表于 2009-6-9 18:34:30 | 显示全部楼层
原帖由 hangtao 于 2009-6-6 20:13 发表
弱弱的问问。这是啥?


gg“有道难题”
您需要登录后才可以回帖 登录 | 加入易码

本版积分规则

Archiver|手机版|小黑屋|EMAX Studio

GMT+8, 2025-5-6 10:47 , Processed in 0.017958 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表