結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
54,204 KB
testcase_01 AC 124 ms
54,276 KB
testcase_02 AC 127 ms
53,864 KB
testcase_03 AC 119 ms
54,536 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 125 ms
54,220 KB
testcase_07 WA -
testcase_08 AC 133 ms
53,748 KB
testcase_09 WA -
testcase_10 AC 130 ms
54,128 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 125 ms
54,208 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 116 ms
52,860 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 129 ms
54,244 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

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)) {
                count++;
            }
            if(_a2 == Math.min(_a1, Math.min(_a2, _a3)) && (_a1 != _a3)) {
                count++;
            }
        }

        System.out.println(count);

        in.close();
    }
}
0