結果

問題 No.982 Add
ユーザー trineutron
提出日時 2020-02-11 18:43:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 482 bytes
コンパイル時間 2,055 ms
コンパイル使用メモリ 196,616 KB
最終ジャッジ日時 2025-01-08 23:42:06
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int a, b;
    cin >> a >> b;
    if (gcd(a, b) != 1) {
        cout << -1 << endl;
        return 0;
    }
    vector<bool> good(a * b);
    for (int i = 0; i < a; i++) {
        for (int j = 0; j < b; j++) {
            if (b * i + a * j >= a * b) continue;
            good.at(b * i + a * j) = true;
        }
    }
    int ans = 0;
    for (int i = 0; i < a * b; i++) ans += !good.at(i);
    cout << ans << endl;
}
0