Official

B - ABC400 Party Editorial by en_translator


For beginners

It is sufficient to check if there exists an integer \(B\) such that \(AB = 400\), and report such \(B\) if it exists.

If \(A\) is a divisor of \(400\), then \(B = \frac{400}{A}\) satisfies the condition. Otherwise, no \(B\) satisfies the condition.

One can determine if \(A\) is a divisor of \(400\) using the modulo operation.

Sample code (C++)

#include <bits/stdc++.h>
using namespace std;

int main() {
	int a;
	cin >> a;
	if (400 % a == 0) cout << 400 / a << '\n';
	else cout << -1 << '\n';
}

posted:
last update: