Connection Status:
Competition Arena > MegaCoolNumbersEasy
SRM 431 · 2008-12-23 · by Gluk · Simple Search, Iteration
Class Name: MegaCoolNumbersEasy
Return Type: int
Method Name: count
Arg Types: (int)
Problem Statement

Problem Statement

A positive integer is called a mega cool number if its digits form an arithmetic progression. An arithmetic progression is a sequence of numbers in which the difference between any two consecutive numbers is the same. Return the number of mega cool numbers between 1 and N, inclusive.

Constraints

  • N will be between 1 and 1,000, inclusive.
Examples
0)
1
Returns: 1

The only mega cool number not greater than 1 is 1.

1)
110
Returns: 99

All numbers between 1 and 99 are mega cool.

2)
500
Returns: 119
3)
209
Returns: 104
4)
2
Returns: 2

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

Coding Area

Language: C++17 · define a public class MegaCoolNumbersEasy with a public method int count(int N) · 87 test cases · 2 s / 256 MB per case

Submitting as anonymous