-
Notifications
You must be signed in to change notification settings - Fork 0
/
20290.cpp
36 lines (29 loc) · 941 Bytes
/
20290.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <cmath>
using namespace std;
// Function to count multiples of x in the range [l, r]
long long countMultiples(long long l, long long r, long long x) {
return r / x - (l - 1) / x;
}
int main() {
int t;
cin >> t; // Read the number of test cases
while (t--) {
long long l, r, k;
cin >> l >> r >> k;
int operations = 0;
// Check for multiples in the range
// We try values for x from 1 to the point where the multiples exceed the range
for (long long x = 1; x * x <= r; ++x) {
if (countMultiples(l, r, x) >= k) {
operations++;
}
if (x != r / x && countMultiples(l, r, r / x) >= k) {
operations++;
}
}
// Output the result for this test case
cout << operations << endl;
}
return 0;
}