Connection Status:
Competition Arena > DivToZero
SRM 262 · 2005-09-09 · by Softwalker · Simple Math
Class Name: DivToZero
Return Type: String
Method Name: lastTwo
Arg Types: (int, int)
Problem Statement

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.

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"

Submissions are judged against all 44 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class DivToZero with a public method string lastTwo(int num, int factor) · 44 test cases · 2 s / 256 MB per case

Submitting as anonymous