公式
B - ABC400 Party 解説 by en_translator
For beginners
- If you are new to learning programming and do not know where to start, please try Problem A "Welcome to AtCoder" from practice contest. There you can find a sample code for each language.
- Also, if you are not familiar with problems in programming contests, we recommend you to try some problems in "AtCoder Beginners Selection".
- 「C++入門 AtCoder Programming Guide for beginners (APG4b)」 is a C++ tutorial for competitive programmers. Sadly, this is only in Japanese too.
- 「Python入門 AtCoder Programming Guide for beginners (APG4bPython)」 is a Python tutorial for competitive programmers. Again, this is only in Japanese.
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';
}
投稿日時:
最終更新: