Felix Halim .NET  
Google 

Problem Statement

Let X and Y be positive integers. We say that Y is a divisor of X if and only if there is a positive integer Z such that X = Y*Z. You will be given a String[] numbers. Each element in this String[] will contain a positive integer. For each of the given integers compute the sum of its positive divisors, itself excluded. Return a String[] containing the computed sums in the same order, with no unnecessary leading zeroes.

Definition

Class:              PerfectNumbers
Method:             sumDivisors
Parameters:         String[]
Returns:            String[]
Method signature:   String[] sumDivisors(String[] numbers)
(be sure your method is public)

Notes

All the numbers in the input, and all the numbers you should output will fit into 64-bit signed integer variables.

Constraints

  • numbers will contain between 1 and 50 elements, inclusive.
  • Each element in numbers contains between 1 and 13 digits ('0'-'9'), inclusive.
  • No element in numbers will contain leading zeroes.

Examples

0)

{"6"}
Returns: {"6" }
The divisors of 6 (other than 6 itself) are 1, 2, and 3. Their sum is 1+2+3 = 6.

1)

{"28"}
Returns: {"28" }
Divisors of 28 are 1, 2, 4, 7, and 14, and their sum is 1+2+4+7+14 = 28.
2)

{"4", "8", "16", "32"}
Returns: {"3", "7", "15", "31" }

3)

{"13", "47", "997"}
Returns: {"1", "1", "1" }

4)

{"510510"}
Returns: {"1231314" }
510510 = 2*3*5*7*11*13*17
5)

{"235152", "235326326132", "1234567890123"}
Returns: {"461232", "176530725964", "411987510213" }

6)

{"9999999999999"}
Returns: {"4903272088641" }
This is the largest valid input number.
7)

{"1"}
Returns: {"0" }
And this is the smallest valid input.

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.


Google India Code Jam 2006 - Table of Contents

  1. Main Page - Google India Code Jam 2006
  2. Qualification Round
  3. Elimination Round
  4. Championship Round
  5. Links/Blogs/News

© Felix Halim 2009 (Loaded in 0.03009 secs)