RefactorableNumber
SRM 343 · 2007-03-22 · by connect4
SRM 343 · 2007-03-22 · by connect4 · Brute Force, Math
Problem Statement
Problem Statement
A refactorable number is defined to be a number that is divisble by the number of distinct factors that it has. Examples of refactorable numbers include 1 (1 factor), 12 (6 factors), and 9 (3 factors), but not 7 (2 factors) or 16 (5 factors).
You will be given two
Constraints
- low will be between 1 and 2,000,000, inclusive.
- high will be between low and 2,000,000, inclusive.
Examples
0)
1 10 Returns: 4
There are 4 refactorable numbers between 1 and 10, namely: 1, 2, 8, and 9.
1)
10 100 Returns: 12
2)
25 35 Returns: 0
3)
123 4567 Returns: 315
4)
1 2000000 Returns: 85803
Submissions are judged against all 42 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class RefactorableNumber with a public method int count(int low, int high) · 42 test cases · 2 s / 256 MB per case