Untitled
unknown
plain_text
6 days ago
567 B
2
Indexable
Never
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int l, r, b, k; cin >> l >> r >> b >> k; int ans = 0; int flag = false; if (l <= b) ans = b * k; else { for (int i = l; i <= r; i++) { if (i % b == 0) { ans = i * k; flag = true; break; } } if (!flag) { ans = ceil(1.0 * l / b) * b * k; } } cout << ans << "\n"; }
Leave a Comment