結果

問題 No.358 も~っと!門松列
ユーザー spaciaspacia
提出日時 2016-06-08 14:58:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 1,000 ms
コード長 703 bytes
コンパイル時間 2,542 ms
コンパイル使用メモリ 76,584 KB
実行使用メモリ 41,720 KB
最終ジャッジ日時 2024-04-17 09:44:48
合計ジャッジ時間 6,052 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
41,284 KB
testcase_01 AC 125 ms
41,124 KB
testcase_02 AC 128 ms
41,720 KB
testcase_03 AC 125 ms
41,432 KB
testcase_04 AC 127 ms
41,124 KB
testcase_05 AC 132 ms
41,128 KB
testcase_06 AC 125 ms
41,220 KB
testcase_07 AC 122 ms
41,124 KB
testcase_08 AC 120 ms
41,460 KB
testcase_09 AC 120 ms
41,396 KB
testcase_10 AC 115 ms
41,376 KB
testcase_11 AC 122 ms
41,376 KB
testcase_12 AC 121 ms
41,496 KB
testcase_13 AC 120 ms
41,420 KB
testcase_14 AC 123 ms
41,252 KB
testcase_15 AC 127 ms
41,512 KB
testcase_16 AC 111 ms
41,256 KB
testcase_17 AC 134 ms
41,288 KB
testcase_18 AC 124 ms
40,252 KB
testcase_19 AC 129 ms
41,364 KB
testcase_20 AC 127 ms
40,896 KB
testcase_21 AC 120 ms
41,124 KB
testcase_22 AC 129 ms
41,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		System.out.println(solve(a, b, c));

		sc.close();

	}

	public static String solve (int a, int b, int c) {

		if (isKadomatsu(a, b, c)) return "INF";
		if (a == b || a == c || b == c) return "0";

		int ret = 0, lim = Math.max(Math.max(a, b), c);
		for (int i = 2; i <= lim; i++)
			if (isKadomatsu(a % i, b % i, c % i)) ret++;
		return ret + "";

	}

	public static boolean isKadomatsu (int a, int b, int c) {
		return ((b < a && b < c) || (b > a && b > c)) && a != b && a != c && b != c;
	}

}
0