SquareFree
SRM 190 · 2004-04-06 · by dgarthur
Problem Statement
A positive integer is said to be squarefree if it is divisible by no perfect square larger than 1. For example, the first few squarefree numbers are {1, 2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, ...}. Create a class SquareFree that contains a method getNumber, which is given an
Constraints
- n will be between 1 and 1,000,000,000 inclusive.
1 Returns: 1
One is the smallest squarefree number.
13 Returns: 19
See the list of squarefree numbers given in the problem statement.
100 Returns: 163
1234567 Returns: 2030745
1000000000 Returns: 1644934081
Submissions are judged against all 63 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class SquareFree with a public method int getNumber(int n) · 63 test cases · 2 s / 256 MB per case