Official

A - Scary Fee Editorial by en_translator


For beginners

Implementation approach

Let \(1000m\) be the amount of withdrawal. Then the condition \(1000m + Cm \leq X\) must be met.

Therefore, the maximum possible \(M\) is the quotient when \(X\) is divided by \((1000+C)\), rounded down. The answer can be obtained by multiplying this by \(1000\).

Sample code (C++)

#include <iostream>
using std::cin;
using std::cout;

int main (void) {
	int x, c;
	cin >> x >> c;

	int cnt = x / (1000 + c);
	int ans = cnt * 1000;
	
	cout << ans << "\n";
	
	return 0;
}

posted:
last update: