結果

問題 No.1352 Three Coins
ユーザー Mister
提出日時 2021-01-24 13:41:25
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 711 bytes
コンパイル時間 634 ms
コンパイル使用メモリ 73,072 KB
最終ジャッジ日時 2025-01-18 07:47:25
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 1 "main.cpp"
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;
constexpr int X = 10000000;

void solve() {
    int a, b, c;
    cin >> a >> b >> c;

    if (gcd(gcd(a, b), c) != 1) {
        cout << "INF\n";
        return;
    }

    vector<bool> ok(X + 1, false);
    ok[0] = true;

    int ans = 0;
    for (int x = 0; x <= X; ++x) {
        if (ok[x]) {
            if (x + a <= X) ok[x + a] = true;
            if (x + b <= X) ok[x + b] = true;
            if (x + c <= X) ok[x + c] = true;
        } else {
            ++ans;
        }
    }

    cout << ans << "\n";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    solve();

    return 0;
}
0