Plates
SRM 135 · 2003-02-11 · by axchma
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
For example, given the
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')
"222" Returns: 777
plates are made of three digits starting from "000" and ending with "999".
"TA4KA" Returns: 1227355
"KAPETA" Returns: 189835177
"MAPA3M" Returns: 63875149
"ZZZZZ" Returns: 0
Submissions are judged against all 38 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
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