結果

問題 No.358 も~っと!門松列
ユーザー YamaKasaYamaKasa
提出日時 2018-05-22 21:08:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 1,000 ms
コード長 809 bytes
コンパイル時間 2,659 ms
コンパイル使用メモリ 73,940 KB
実行使用メモリ 57,728 KB
最終ジャッジ日時 2023-09-11 01:20:50
合計ジャッジ時間 6,639 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,720 KB
testcase_01 AC 120 ms
55,628 KB
testcase_02 AC 117 ms
55,944 KB
testcase_03 AC 120 ms
55,992 KB
testcase_04 AC 120 ms
56,016 KB
testcase_05 AC 120 ms
55,468 KB
testcase_06 AC 121 ms
56,140 KB
testcase_07 AC 121 ms
55,824 KB
testcase_08 AC 118 ms
55,936 KB
testcase_09 AC 121 ms
56,660 KB
testcase_10 AC 120 ms
55,972 KB
testcase_11 AC 119 ms
55,840 KB
testcase_12 AC 121 ms
57,728 KB
testcase_13 AC 120 ms
55,496 KB
testcase_14 AC 120 ms
55,936 KB
testcase_15 AC 120 ms
55,424 KB
testcase_16 AC 120 ms
55,524 KB
testcase_17 AC 121 ms
55,456 KB
testcase_18 AC 120 ms
55,336 KB
testcase_19 AC 120 ms
55,304 KB
testcase_20 AC 125 ms
55,980 KB
testcase_21 AC 122 ms
55,468 KB
testcase_22 AC 119 ms
56,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A1 = scan.nextInt();
		int A2 = scan.nextInt();
		int A3 = scan.nextInt();
		scan.close();

		int max = A1;
		if(max < A2) {
			max = A2;
		}
		if(max < A3) {
			max = A3;
		}

		int cnt = 0;
		if(isCheck(A1, A2, A3)) {
			System.out.println("INF");
			System.exit(0);
		}else {
			for(int i = 2; i <= max; i++) {
				int B1 = A1 % i;
				int B2 = A2 % i;
				int B3 = A3 % i;
				if(isCheck(B1, B2, B3)) {
					cnt ++;
				}
			}
		}
		System.out.println(cnt);
	}
	public static boolean isCheck(int A1, int A2, int A3) {
		if(A1 > A2 && A2 < A3 && A1 != A3) {
			return true;
		}else if(A1 < A2 && A2 > A3 && A1 != A3) {
			return true;
		}else {
			return false;
		}
	}
}
0