結果

問題 No.358 も~っと!門松列
ユーザー mitsuomitsuo
提出日時 2016-05-04 12:28:49
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 936 bytes
コンパイル時間 2,607 ms
コンパイル使用メモリ 78,076 KB
実行使用メモリ 54,416 KB
最終ジャッジ日時 2024-04-15 11:15:18
合計ジャッジ時間 6,466 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 143 ms
54,072 KB
testcase_01 AC 139 ms
53,836 KB
testcase_02 AC 137 ms
54,064 KB
testcase_03 AC 134 ms
54,268 KB
testcase_04 AC 136 ms
54,084 KB
testcase_05 AC 134 ms
54,216 KB
testcase_06 AC 136 ms
54,256 KB
testcase_07 AC 139 ms
54,224 KB
testcase_08 AC 137 ms
54,268 KB
testcase_09 AC 134 ms
54,084 KB
testcase_10 AC 137 ms
54,300 KB
testcase_11 AC 140 ms
54,376 KB
testcase_12 AC 139 ms
54,288 KB
testcase_13 AC 140 ms
54,248 KB
testcase_14 AC 139 ms
54,268 KB
testcase_15 AC 137 ms
54,228 KB
testcase_16 AC 135 ms
54,004 KB
testcase_17 AC 134 ms
54,108 KB
testcase_18 AC 135 ms
53,796 KB
testcase_19 AC 142 ms
54,416 KB
testcase_20 AC 136 ms
54,156 KB
testcase_21 AC 140 ms
53,996 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) {

		if (a1 != a2 && a2 != a3 && a1 != a3) {
			if (a2 < a1 && a2 < a3) {
				return "INF";
			}
			if (a2 > a1 && a2 > a3) {
				return "INF";
			}
		}

		
		int ans = 0;
		for (int p = 1; p < 1000; 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++;
				}
			}
		}
		
		return String.valueOf(ans);

	}
}
0