結果

問題 No.358 も~っと!門松列
ユーザー matsuyoshi30matsuyoshi30
提出日時 2018-10-03 23:28:12
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,150 bytes
コンパイル時間 2,376 ms
コンパイル使用メモリ 78,748 KB
実行使用メモリ 56,448 KB
最終ジャッジ日時 2024-04-20 14:54:52
合計ジャッジ時間 6,316 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
41,484 KB
testcase_01 AC 137 ms
41,564 KB
testcase_02 AC 135 ms
41,268 KB
testcase_03 AC 133 ms
40,924 KB
testcase_04 AC 136 ms
41,564 KB
testcase_05 AC 138 ms
41,424 KB
testcase_06 AC 138 ms
41,608 KB
testcase_07 AC 134 ms
41,236 KB
testcase_08 AC 136 ms
41,468 KB
testcase_09 AC 138 ms
41,496 KB
testcase_10 AC 121 ms
40,084 KB
testcase_11 AC 136 ms
41,356 KB
testcase_12 AC 135 ms
41,388 KB
testcase_13 AC 136 ms
41,424 KB
testcase_14 AC 139 ms
41,560 KB
testcase_15 WA -
testcase_16 AC 122 ms
40,292 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 139 ms
41,548 KB
testcase_20 AC 139 ms
41,492 KB
testcase_21 WA -
testcase_22 AC 138 ms
41,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a1 = in.nextInt();
        int a2 = in.nextInt();
        int a3 = in.nextInt();

        int max = Math.max(a1, Math.max(a2, a3));
        int min = Math.min(a1, Math.min(a2, a3));
        if((a2 == min) && (a1 != a3)) {
            System.out.println("INF");
            return;
        }
        if((a1 == a2) || (a2 == a3) || (a3 == a1)) {
            System.out.println(0);
            return;
        }
        int count = 0;

        for(int i=1; i<=max; i++) {
            int _a1 = a1 % i;
            int _a2 = a2 % i;
            int _a3 = a3 % i;
            if(_a2 == Math.max(_a1, Math.max(_a2, _a3)) && (_a1 != _a3) && (_a1 != _a2) && (_a2 != _a3)) {
                count++;
            }
            if(_a2 == Math.min(_a1, Math.min(_a2, _a3)) && (_a1 != _a3) && (_a1 != _a2) && (_a2 != _a3)) {
                count++;
            }
        }

        System.out.println(count);

        in.close();
    }
}
0