結果

問題 No.358 も~っと!門松列
ユーザー kokatsu
提出日時 2022-05-22 21:33:15
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 534 bytes
コンパイル時間 1,434 ms
コンパイル使用メモリ 176,808 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-22 15:18:43
合計ジャッジ時間 2,351 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main() {
    auto A = readln.chomp.split.to!(int[]);

    bool f(int[] x) {
        bool res = true;
        foreach (i; 0 .. 3) {
            res &= (x[i] != x[(i+1)%3]);
        }
        int mn = x.minElement, mx = x.maxElement;
        res &= (x[1] == mn || x[1] == mx);
        return res;
    }

    if (f(A)) {
        writeln("INF");
        return;
    }

    int res, L = A.maxElement;
    foreach (i; 1 .. L+1) {
        auto B = A.dup;
        B[] %= i;
        if (f(B)) ++res;
    }

    res.writeln;
}
0