結果

問題 No.358 も~っと!門松列
ユーザー spaciaspacia
提出日時 2016-06-08 14:56:21
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 753 bytes
コンパイル時間 2,330 ms
コンパイル使用メモリ 86,228 KB
実行使用メモリ 41,632 KB
最終ジャッジ日時 2024-04-17 09:44:09
合計ジャッジ時間 6,170 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
41,620 KB
testcase_01 AC 127 ms
41,172 KB
testcase_02 AC 131 ms
41,356 KB
testcase_03 AC 131 ms
41,180 KB
testcase_04 AC 122 ms
40,016 KB
testcase_05 AC 119 ms
41,532 KB
testcase_06 AC 128 ms
41,508 KB
testcase_07 AC 123 ms
40,028 KB
testcase_08 AC 134 ms
41,396 KB
testcase_09 AC 138 ms
41,308 KB
testcase_10 AC 130 ms
41,204 KB
testcase_11 AC 131 ms
41,360 KB
testcase_12 AC 131 ms
41,452 KB
testcase_13 WA -
testcase_14 AC 132 ms
41,336 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 119 ms
39,864 KB
testcase_21 WA -
testcase_22 AC 133 ms
41,392 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) && b == 1) 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++;
				//System.out.println(i);
			}
		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