結果

問題 No.358 も~っと!門松列
ユーザー GrenacheGrenache
提出日時 2016-04-29 11:39:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 1,000 ms
コード長 1,049 bytes
コンパイル時間 3,285 ms
コンパイル使用メモリ 78,048 KB
実行使用メモリ 54,480 KB
最終ジャッジ日時 2024-04-15 05:20:00
合計ジャッジ時間 7,172 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
54,116 KB
testcase_01 AC 129 ms
54,068 KB
testcase_02 AC 129 ms
54,080 KB
testcase_03 AC 127 ms
54,068 KB
testcase_04 AC 134 ms
53,792 KB
testcase_05 AC 128 ms
54,068 KB
testcase_06 AC 131 ms
54,312 KB
testcase_07 AC 131 ms
54,012 KB
testcase_08 AC 130 ms
54,020 KB
testcase_09 AC 130 ms
54,176 KB
testcase_10 AC 128 ms
54,196 KB
testcase_11 AC 131 ms
54,176 KB
testcase_12 AC 118 ms
52,988 KB
testcase_13 AC 131 ms
54,112 KB
testcase_14 AC 133 ms
54,120 KB
testcase_15 AC 132 ms
54,212 KB
testcase_16 AC 128 ms
54,248 KB
testcase_17 AC 130 ms
54,404 KB
testcase_18 AC 130 ms
54,048 KB
testcase_19 AC 130 ms
54,232 KB
testcase_20 AC 132 ms
54,480 KB
testcase_21 AC 132 ms
54,312 KB
testcase_22 AC 131 ms
54,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;


public class Main_yukicoder358 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int[] a = new int[3];
        int max = 0;
        a[0] = sc.nextInt();
        max = Math.max(max, a[0]);
        a[1] = sc.nextInt();
        max = Math.max(max, a[1]);
        a[2] = sc.nextInt();
        max = Math.max(max, a[2]);

        if (isKado(a)) {
        	System.out.println("INF");
        } else {
        	int ret = 0;
        	for (int p = 1; p <= max; p++) {
        		int[] tmp = new int[3];
        		tmp[0] = a[0] % p;
        		tmp[1] = a[1] % p;
        		tmp[2] = a[2] % p;
        		if (isKado(tmp)) {
        			ret++;
        		}
        	}

        	System.out.println(ret);
        }

        sc.close();
    }

	private static boolean isKado(int[] a) {
		if (a[0] == a[1] || a[1] == a[2] || a[2] == a[0]) {
			return false;
		}

		if (a[1] > a[0] && a[1] > a[2]) {
			return true;
		}
		if (a[1] < a[0] && a[1] < a[2]) {
			return true;
		}

		return false;
	}
}
0