結果
| 問題 | No.982 Add |
| コンテスト | |
| ユーザー |
square1001
|
| 提出日時 | 2020-03-01 23:02:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 474 bytes |
| 記録 | |
| コンパイル時間 | 586 ms |
| コンパイル使用メモリ | 68,192 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-13 20:53:18 |
| 合計ジャッジ時間 | 1,768 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / 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 && i <= A * B) ++ans;
if (!ok && i > A * B) ans = inf;
}
if (ans >= inf) cout << -1 << endl;
else cout << ans << endl;
return 0;
}
square1001