結果
問題 | No.982 Add |
ユーザー |
![]() |
提出日時 | 2020-03-01 23:02:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 473 ms / 2,000 ms |
コード長 | 482 bytes |
コンパイル時間 | 511 ms |
コンパイル使用メモリ | 66,304 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 20:53:22 |
合計ジャッジ時間 | 3,242 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <vector> #include <iostream> using namespace std; const int inf = 1012345678; int main() { int A, B; cin >> A >> B; int ans = 0; for (int i = 1; i <= 2 * A * B; ++i) { bool ok = false; for (int j = 0; j <= 2 * B; ++j) { for (int k = 0; k <= 2 * A; ++k) { if (j * A + k * B == i) { ok = true; } } } if (!ok && i <= A * B) ++ans; if (!ok && i > A * B) ans = inf; } if (ans >= inf) cout << -1 << endl; else cout << ans << endl; return 0; }