結果

問題 No.358 も~っと!門松列
ユーザー matsuyoshi30matsuyoshi30
提出日時 2017-02-23 00:02:20
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,099 bytes
コンパイル時間 2,915 ms
コンパイル使用メモリ 75,664 KB
実行使用メモリ 56,552 KB
最終ジャッジ日時 2023-08-29 01:40:26
合計ジャッジ時間 7,078 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,916 KB
testcase_01 AC 122 ms
56,552 KB
testcase_02 AC 121 ms
55,708 KB
testcase_03 AC 121 ms
56,212 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 120 ms
55,912 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 121 ms
55,732 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 119 ms
56,084 KB
testcase_14 WA -
testcase_15 AC 120 ms
56,244 KB
testcase_16 AC 121 ms
55,816 KB
testcase_17 AC 122 ms
55,496 KB
testcase_18 AC 121 ms
56,332 KB
testcase_19 AC 121 ms
55,892 KB
testcase_20 WA -
testcase_21 AC 121 ms
55,988 KB
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 == max || 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