Multiples
SRM 201 · 2004-06-29 · by zoidal
SRM 201 · 2004-06-29 · by zoidal · Brute Force, Simple Math
Problem Statement
Problem Statement
You are to create a class Multiples with a method number, which takes three
Given a range of integers from min to max (inclusive), determine how many numbers within that range are evenly divisible by factor.
Notes
- If x is evenly divisble by y, there exists some integer k such that k * y = x.
Constraints
- min will be between -1000000 and 1000000, inclusive.
- max will be between -1000000 and 1000000, inclusive.
- max will be greater than or equal to min.
- factor will be between 1 and 1000, inclusive.
Examples
0)
0 14 5 Returns: 3
The numbers 0, 5, and 10 are evenly divisible by 5, so this returns 3.
1)
7 24 3 Returns: 6
The numbers 9, 12, 15, 18, 21, 24 are evenly divisible by 3, so this returns 6.
2)
-123456 654321 997 Returns: 780
3)
65456 456789 13 Returns: 30102
4)
798125 987546 789 Returns: 240
Submissions are judged against all 27 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class Multiples with a public method int number(int min, int max, int factor) · 27 test cases · 2 s / 256 MB per case