Chinaunix首页 | 论坛 | 博客
  • 博客访问: 735348
  • 博文数量: 769
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 4985
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-15 16:37
文章分类

全部博文(769)

文章存档

2011年(1)

2008年(768)

我的朋友

分类:

2008-10-15 16:39:56

    SecretSum 是本次 google 竞赛中第二轮淘汰赛的一道分值为 500 分竞赛题。事实上,这道题目反而比同轮比赛中的那道 1000 分值的RecurringNumbers 难(RecurringNumbers 的难度水准充其量不过是道初一学生奥数竞赛题)。好了,闲话少叙,来看 SecretSum 的题目吧:

  一、竞赛题目

  Problem Statement

  We can substitute each digit of a number with a unique letter from ''A'' to ''Z''. This way we can write groups of numbers in a single representation. For example "ABA" can represent any of the following: 101, 151, 343, 767, 929. However, "ABA" cannot mean 555 because each letter must stand for a distinct digit. Furthermore, numbers cannot begin with 0 and thus ''A'' cannot be replaced by 0. Given two such representations num1 and num2 and the result of their summation return the total number of possible combinations of numbers for which the equation holds. If no combinations are possible then return 0.

  Definition

  Class: SecretSum

  Method: countPossible

  Parameters: String, String, String

  Returns: int

  Method signature: int countPossible(String num1, String num2, String result)

  (be sure your method is public)

  Constraints

  - num1, num2, and result will each contain exactly 3 uppercase letters (''A'' - ''Z'').

  Examples

  0)

  "AAA"

[1]     

【责编:huangchunmei】

--------------------next---------------------

阅读(454) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~