結果

問題 No.358 も~っと!門松列
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-05-04 13:59:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 43 ms / 1,000 ms
コード長 1,204 bytes
コンパイル時間 3,311 ms
コンパイル使用メモリ 74,556 KB
実行使用メモリ 49,876 KB
最終ジャッジ日時 2023-10-12 07:57:37
合計ジャッジ時間 4,101 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,496 KB
testcase_01 AC 41 ms
49,532 KB
testcase_02 AC 42 ms
49,236 KB
testcase_03 AC 42 ms
49,244 KB
testcase_04 AC 42 ms
49,368 KB
testcase_05 AC 43 ms
49,876 KB
testcase_06 AC 42 ms
49,364 KB
testcase_07 AC 42 ms
49,308 KB
testcase_08 AC 42 ms
49,508 KB
testcase_09 AC 41 ms
47,404 KB
testcase_10 AC 41 ms
49,240 KB
testcase_11 AC 41 ms
49,428 KB
testcase_12 AC 42 ms
49,344 KB
testcase_13 AC 42 ms
49,308 KB
testcase_14 AC 42 ms
49,296 KB
testcase_15 AC 42 ms
49,384 KB
testcase_16 AC 41 ms
49,244 KB
testcase_17 AC 41 ms
49,852 KB
testcase_18 AC 42 ms
49,256 KB
testcase_19 AC 42 ms
49,344 KB
testcase_20 AC 41 ms
49,232 KB
testcase_21 AC 42 ms
49,332 KB
testcase_22 AC 42 ms
47,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String[] inputs = reader.readLine().split(" ");
        int A1 = Integer.parseInt(inputs[0]);
        int A2 = Integer.parseInt(inputs[1]);
        int A3 = Integer.parseInt(inputs[2]);
        int max = Math.max(Math.max(A1, A2), A3);
        int counter = 0;
        if (isKadomatu(A1, A2, A3)) {
            System.out.println("INF");
        } else {
            for (int i = 1; i <= max; i++) {
                if (isKadomatu(A1 % i, A2 % i, A3 % i)) {
                    counter += 1;
                }
            }
            System.out.println(counter);
        }

    }

    private static boolean isKadomatu(int a, int b, int c) {
        if (a == b || b == c || c == a) {
            return false;
        }

        if (b < a && b < c) {
            return true;
        } else if (a < b && c < b) {
            return true;
        } else {
            return false;
        }
    }
}

0