SquareDigitNumbers
SRM 395 · 2008-03-26 · by connect4
SRM 395 · 2008-03-26 · by connect4 · Brute Force, Simple Math
Problem Statement
Problem Statement
You enjoy working with numbers that contain only square digits (namely, 0, 1, 4 and 9). The sequence containing only these digits is 0, 1, 4, 9, 10, 11, 14... Return the n-th term (indexed from 0) in this sequence.
Constraints
- n will be between 0 and 1000, inclusive.
Examples
0)
0 Returns: 0
The first square digit number is 0.
1)
5 Returns: 11
2)
16 Returns: 100
3)
121 Returns: 1941
4)
123 Returns: 1949
5)
1000 Returns: 99440
Maximum return
Submissions are judged against all 41 archived test cases, of which 6 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class SquareDigitNumbers with a public method int getNumber(int n) · 41 test cases · 2 s / 256 MB per case