TopCoder problem "DivToZero" used in SRM 262 (Division II Level One)



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

0)
    
2000000000
100
Returns: "00"
1)
    
1000
3
Returns: "02"
2)
    
23442
75
Returns: "00"
3)
    
428392
17
Returns: "15"
4)
    
32442
99
Returns: "72"

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=4556

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=7996&pm=4556

Writer:

Softwalker

Testers:

PabloGilberto , brett1479 , Olexiy

Problem categories:

Simple Math