結果

問題 No.358 も~っと!門松列
ユーザー rn4rurn4ru
提出日時 2016-04-17 22:55:38
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 881 bytes
コンパイル時間 1,882 ms
コンパイル使用メモリ 77,944 KB
実行使用メモリ 56,040 KB
最終ジャッジ日時 2024-04-15 02:23:15
合計ジャッジ時間 5,204 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
41,296 KB
testcase_01 AC 116 ms
41,416 KB
testcase_02 AC 118 ms
41,676 KB
testcase_03 AC 122 ms
41,668 KB
testcase_04 AC 108 ms
41,108 KB
testcase_05 AC 118 ms
41,560 KB
testcase_06 AC 118 ms
41,608 KB
testcase_07 AC 111 ms
41,564 KB
testcase_08 AC 107 ms
41,644 KB
testcase_09 AC 105 ms
41,580 KB
testcase_10 AC 118 ms
41,376 KB
testcase_11 AC 108 ms
41,572 KB
testcase_12 AC 108 ms
41,308 KB
testcase_13 WA -
testcase_14 AC 118 ms
41,632 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 117 ms
41,136 KB
testcase_21 WA -
testcase_22 AC 105 ms
41,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A[] = new int[3];
		for (int i = 0; i < 3; i++) {
			A[i] = scanner.nextInt();
		}

		System.out.println(new Solver().solve(A));

	}

}

class Solver {

	public String solve(int[] a) {
		if (a[0] == a[1] || a[0] == a[2] || a[1] == a[2]) {
			return "0";
		}

		int sum = 0;
		int max = Math.max(Math.max(a[0], a[1]), a[2]);
		for (int i = 1; i <= max; i++) {
			int b1 = a[0] % i;
			int b2 = a[1] % i;
			int b3 = a[2] % i;
			if (isKadomatsu(b1, b2, b3)) {
				sum++;
			}
		}
		if (sum > 0) {
			return String.valueOf(sum);
		} else {
			return "INF";
		}
	}

	private boolean isKadomatsu(int b1, int b2, int b3) {
		if (b1 == b2 || b1 == b3 || b2 == b3) {
			return false;
		}
		return (b2 > b1 && b2 > b3) || (b2 < b1 && b2 < b3);
	}

}
0