Connection Status:
Competition Arena > Plates
SRM 135 · 2003-02-11 · by axchma
Class Name: Plates
Return Type: long
Method Name: numLeft
Arg Types: (string)
Problem Statement

Problem Statement

Recently all cars in NJ had a specific pattern of digits and letters for their license plate numbers. For example, the license plate number "UG830H" follows the pattern "LLDDDL", where 'L' stands for letter, and 'D' stands for digit. 17,576,000 distinct license plate numbers can be generated using this format. As the population and the number of cars grows, new formats appear. For example, the new format in NJ is "LLLDDL" (as in "MEL87H"). The new format will be able to number 45,697,600 cars. Assume that plates are assigned in lexicographic order (the order they would appear in a dictionary. i.e. "AAA" comes before "AAB" and "AA1" comes before "AA7"). For practical purposes it is important to know how many plates are available for further assignment at each moment in time.

Your task is, given a String representing a license plate number, return the total number of possible license plates following the same pattern as the input that can be assigned after the given plate number.

For example, given the String "D43", we must count all of the plate numbers that have one letter, followed by two digits, and come after "D43". Any sequence that starts with a letter after 'D' works (there are 100*22 of these), as does any sequence that starts with the letter 'D' and is followed by a two digit number greater than "43" (there are 56 of these).

Notes

  • We assume that only upper-case letters and digits can be used in plate numbers.
  • Digit 0 (zero) should be treated like any other digit. That is, the plate number can start with 0, if it starts with a digit.
  • The 64 bit datatype in C++ is long long.

Constraints

  • plateNum contains between 3 and 8 characters inclusive
  • each character of plateNum is a digit ('0'-'9') or an upper-case letter ('A'-'Z')
Examples
0)
"222"
Returns: 777

plates are made of three digits starting from "000" and ending with "999".

1)
"TA4KA"
Returns: 1227355
2)
"KAPETA"
Returns: 189835177
3)
"MAPA3M"
Returns: 63875149
4)
"ZZZZZ"
Returns: 0

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

Coding Area

Language: C++17 · define a public class Plates with a public method long long numLeft(string plateNum) · 38 test cases · 2 s / 256 MB per case

Submitting as anonymous