結果
問題 |
No.982 Add
|
ユーザー |
![]() |
提出日時 | 2020-03-01 23:02:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 459 bytes |
コンパイル時間 | 687 ms |
コンパイル使用メモリ | 67,508 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-13 20:53:16 |
合計ジャッジ時間 | 2,019 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 9 WA * 14 |
ソースコード
#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 <= B; ++j) { for (int k = 0; k <= A; ++k) { if (j * A + k * B == i) { ok = true; } } } if (!ok) ++ans; if (!ok && i > A* B) ans = inf; } if (ans >= inf) cout << -1 << endl; else cout << ans << endl; return 0; }