NumberOfDivisors
SRM 370 · 2007-10-09 · by mateuszek
SRM 370 · 2007-10-09 · by mateuszek · Dynamic Programming, Math
Problem Statement
Problem Statement
Return the smallest positive integer that has exactly k divisors. If this number is greater than 1018, return -1 instead.
Constraints
- k will be between 1 and 50000, inclusive.
Examples
0)
1 Returns: 1
1)
2 Returns: 2
2)
3 Returns: 4
3)
4 Returns: 6
4)
6 Returns: 12
The 6 divisors of 12 are: 1, 2, 3, 4, 6, 12.
Submissions are judged against all 105 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class NumberOfDivisors with a public method long long smallestNumber(int k) · 105 test cases · 2 s / 256 MB per case