結果

問題 No.1352 Three Coins
コンテスト
ユーザー Mister
提出日時 2021-01-24 13:41:25
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 61 ms / 2,000 ms
+ 845µs
コード長 711 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 894 ms
コンパイル使用メモリ 92,176 KB
実行使用メモリ 9,920 KB
最終ジャッジ日時 2026-10-10 13:50:33
合計ジャッジ時間 3,057 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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