結果

問題 No.358 も~っと!門松列
ユーザー rn4rurn4ru
提出日時 2016-04-17 22:53:43
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 942 bytes
コンパイル時間 2,671 ms
コンパイル使用メモリ 85,196 KB
実行使用メモリ 55,504 KB
最終ジャッジ日時 2024-04-15 02:22:56
合計ジャッジ時間 7,476 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 120 ms
54,104 KB
testcase_02 WA -
testcase_03 AC 118 ms
54,168 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 123 ms
54,172 KB
testcase_07 WA -
testcase_08 AC 121 ms
54,080 KB
testcase_09 WA -
testcase_10 AC 125 ms
54,176 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

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)) {
				System.out.println(i + ": " + 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