-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add solution for Codeforces Problem B (Div-3 1650)
- Loading branch information
1 parent
e1dc831
commit 2d6a923
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* author : nxtsourav7 | ||
* created : 2024-12-21 22:24:32 | ||
**/ | ||
|
||
#include<bits/stdc++.h> | ||
using namespace std; | ||
|
||
#define endl "\n" | ||
#define int long long | ||
#define sz(x) (int)(x).size() | ||
#define all(x) (x).begin(), (x).end() | ||
#define rall(x) (x).rbegin(), (x).rend() | ||
#define test(T) for(int t = 1; t <= T; ++t) | ||
#define fastIO cin.tie(0)->sync_with_stdio(0) | ||
|
||
void solve() { | ||
int l, r, a; | ||
cin >> l >> r >> a; | ||
|
||
int ans = r / a + r % a; | ||
int x = r - r % a - 1; | ||
if(x >= l) { | ||
ans = max(ans, x / a + x % a); | ||
} | ||
cout << ans; | ||
} | ||
|
||
int32_t main() { | ||
fastIO; | ||
bool Q = true; | ||
int T = Q? (cin >> T, T) : 1; | ||
test(T) { | ||
solve(); | ||
cout << endl; | ||
} | ||
|
||
return 0; | ||
} |