結果

問題 No.358 も~っと!門松列
ユーザー mitsuomitsuo
提出日時 2016-05-04 12:20:05
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 870 bytes
コンパイル時間 2,205 ms
コンパイル使用メモリ 77,932 KB
実行使用メモリ 54,500 KB
最終ジャッジ日時 2024-04-15 11:15:11
合計ジャッジ時間 6,200 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
54,500 KB
testcase_01 AC 130 ms
53,956 KB
testcase_02 AC 132 ms
53,992 KB
testcase_03 AC 130 ms
53,956 KB
testcase_04 AC 130 ms
53,884 KB
testcase_05 AC 130 ms
54,160 KB
testcase_06 AC 131 ms
54,244 KB
testcase_07 AC 130 ms
53,860 KB
testcase_08 AC 129 ms
54,328 KB
testcase_09 AC 128 ms
53,956 KB
testcase_10 AC 129 ms
54,060 KB
testcase_11 AC 131 ms
53,696 KB
testcase_12 AC 129 ms
54,016 KB
testcase_13 AC 136 ms
53,816 KB
testcase_14 AC 128 ms
53,956 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 135 ms
53,900 KB
testcase_18 WA -
testcase_19 AC 128 ms
54,004 KB
testcase_20 AC 134 ms
54,052 KB
testcase_21 AC 130 ms
53,832 KB
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input;
		if (args.length == 0) {
			input = sc.nextLine();
		} else {
			input = args[0];
		}
		String[] d = input.split(" ");
		int a1 = Integer.valueOf(d[0]);
		int a2 = Integer.valueOf(d[1]);
		int a3 = Integer.valueOf(d[2]);

		System.out.println(solve(a1, a2, a3));

		sc.close();
	}

	public static String solve(int a1, int a2, int a3) {
		int m = 1000;
		int ans = 0;
		for (int p = 1; p < m; p++) {

			int p1 = a1 % p;
			int p2 = a2 % p;
			int p3 = a3 % p;

			if (p1 != p2 && p2 != p3 && p1 != p3) {
				if (p2 < p1 && p2 < p3) {
					ans++;
				}
				if (p2 > p1 && p2 > p3) {
					ans++;
				}
			}
		}
		if (ans > Math.max(a1, Math.max(a2, a3))) {
			return "INF";
		} else {
			return String.valueOf(ans);
		}

	}
}
0