結果

問題 No.358 も~っと!門松列
ユーザー oooooba
提出日時 2021-02-11 10:37:44
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 1,000 ms
コード長 1,134 bytes
コンパイル時間 984 ms
コンパイル使用メモリ 106,776 KB
最終ジャッジ日時 2025-01-18 17:19:55
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <optional>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

bool f(vector<int32_t> &as) {
    bool eq = false;
    for (auto i = 0; i < 3; ++i) {
        eq |= as[i] == as[(i + 1) % 3];
    }
    return eq;
}

bool g(vector<int32_t> &as) {
    return max_element(as.begin(), as.end()) - as.begin() == 1 ||
           min_element(as.begin(), as.end()) - as.begin() == 1;
}

int main() {
    vector<int32_t> as(3);
    for (auto i = 0; i < 3; ++i) {
        cin >> as[i];
    }
    if (f(as)) {
        cout << 0 << endl;
        return 0;
    }
    if (g(as)) {
        cout << "INF" << endl;
        return 0;
    }
    int32_t ans = 0;
    for (auto i = 1, e = *max_element(as.begin(), as.end()); i <= e; ++i) {
        vector<int32_t> as2(3);
        for (auto j = 0; j < 3; ++j) {
            as2[j] = as[j] % i;
        }
        if (f(as2))
            continue;
        if (g(as2))
            ++ans;
    }
    cout << ans << endl;
    return 0;
}
0