Problem Statement
????
在有道公司,每个月末都会为该月生日的员工举行集体的生日庆祝活动,每次活动都会做游戏。有一次的游戏是这样的,参加者会拿到一张有一段字符的纸条,字符只有(‘a’-‘z’), ‘+’, 还有‘*’。 ‘*’字符的能量是在它左侧的‘+’的个数。参加者需要在规定时间内计算出每个‘*’的能量,并且将这些能量相加,把结果告诉主持人。如果没有‘*’字符,则应该告诉主持人结果为0。如果回答正确,则可以获得奖品。
对于给定的字符串,返回所有’*’字符的能量和。
Definition
????
Class:
PowerString
Method:
power
Parameters:
string
Returns:
int
Method signature:
int power(string s)
(be sure your method is public)
????
Constraints
-
s 将包含1~50个字符
-
s 中只可能包括字符’*’, ‘+’, ‘a’-‘z’ (注意都是小写)
Examples
0)
????
"+**"
Returns: 2
对应*号的得分为1+1=2.
1)
????
"fd+*fd"
Returns: 1
对应*号的得分为1
2)
????
"*+*+*+*+*"
Returns: 10
对应*号的得分为 0+1+2+3+4=10.
3)
????
"+a*b+c+*d*+f*g"
Returns: 11
4)
????
"abcdefgh"
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.
第二题
Problem Statement
????
双倍超立方数是指一个正整数可以正好被拆分为两种不同的a^3+b^3的方式,其中a,b均为整数且0<a<=b。对于任何一个指定的 int n, 返回所有的小于等于n的双倍超立方数的个数。
Definition
????
Class:
TwiceSuperCubic
Method:
count
Parameters:
int
Returns:
int
Method signature:
int count(int n)
(be sure your method is public)
????
Constraints
-
n取值范围为1到1,000,000,000(含)
Examples
0)
????
1
Returns: 0
1)
????
1729
Returns: 1
1729=1^3+12^3 1729=9^3+10^3
2)
????
475574
Returns: 27
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.
????
在有道公司,每个月末都会为该月生日的员工举行集体的生日庆祝活动,每次活动都会做游戏。有一次的游戏是这样的,参加者会拿到一张有一段字符的纸条,字符只有(‘a’-‘z’), ‘+’, 还有‘*’。 ‘*’字符的能量是在它左侧的‘+’的个数。参加者需要在规定时间内计算出每个‘*’的能量,并且将这些能量相加,把结果告诉主持人。如果没有‘*’字符,则应该告诉主持人结果为0。如果回答正确,则可以获得奖品。
对于给定的字符串,返回所有’*’字符的能量和。
Definition
????
Class:
PowerString
Method:
power
Parameters:
string
Returns:
int
Method signature:
int power(string s)
(be sure your method is public)
????
Constraints
-
s 将包含1~50个字符
-
s 中只可能包括字符’*’, ‘+’, ‘a’-‘z’ (注意都是小写)
Examples
0)
????
"+**"
Returns: 2
对应*号的得分为1+1=2.
1)
????
"fd+*fd"
Returns: 1
对应*号的得分为1
2)
????
"*+*+*+*+*"
Returns: 10
对应*号的得分为 0+1+2+3+4=10.
3)
????
"+a*b+c+*d*+f*g"
Returns: 11
4)
????
"abcdefgh"
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.
第二题
Problem Statement
????
双倍超立方数是指一个正整数可以正好被拆分为两种不同的a^3+b^3的方式,其中a,b均为整数且0<a<=b。对于任何一个指定的 int n, 返回所有的小于等于n的双倍超立方数的个数。
Definition
????
Class:
TwiceSuperCubic
Method:
count
Parameters:
int
Returns:
int
Method signature:
int count(int n)
(be sure your method is public)
????
Constraints
-
n取值范围为1到1,000,000,000(含)
Examples
0)
????
1
Returns: 0
1)
????
1729
Returns: 1
1729=1^3+12^3 1729=9^3+10^3
2)
????
475574
Returns: 27
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.