Skip to content

Commit

Permalink
add solution for Codeforces Problem B (Div-3 1650)
Browse files Browse the repository at this point in the history
  • Loading branch information
nxtsourav7 committed Dec 21, 2024
1 parent e1dc831 commit 2d6a923
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Codeforces/Div-3/1650/B_DIV_MOD.cpp
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;
}

0 comments on commit 2d6a923

Please sign in to comment.