TopcoderArchiveVisit Topcoder
SRM9 Sep 2005
SRM 262

DivToZero

Problem statement, definition, constraints, and public examples.

Problem Statement

You are given an integer num from which you should replace the last two digits such that the resulting number is divisible by factor and is also the smallest possible number. Return the two replacement digits as a String.

For instance:

if num = 275, and factor = 5, you would return "00" because 200 is divisible by 5.
if num = 1021, and factor = 11, you would return "01" because 1001 is divisible by 11.
if num = 70000, and factor = 17, you would return "06" because 70006 is divisible by 17.

Definition

Class:
DivToZero
Method:
lastTwo
Parameters:
int, int
Returns:
String
Method signature:
String lastTwo(int num, int factor)
(be sure your method is public)

Constraints

  • factor must be between 1 and 100, inclusive.
  • num must be between 100 and 2,000,000,000, inclusive.

Examples

  1. 2000000000
    100
    Returns: "00"
  2. 1000
    3
    Returns: "02"
  3. 23442
    75
    Returns: "00"
  4. 428392
    17
    Returns: "15"
  5. 32442
    99
    Returns: "72"
Back to all problems