結果

問題 No.358 も~っと!門松列
ユーザー htensaihtensai
提出日時 2019-11-21 15:28:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 1,000 ms
コード長 674 bytes
コンパイル時間 3,334 ms
コンパイル使用メモリ 79,044 KB
実行使用メモリ 41,532 KB
最終ジャッジ日時 2024-04-18 09:51:47
合計ジャッジ時間 7,399 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
40,008 KB
testcase_01 AC 129 ms
41,260 KB
testcase_02 AC 133 ms
41,416 KB
testcase_03 AC 130 ms
41,160 KB
testcase_04 AC 136 ms
41,064 KB
testcase_05 AC 121 ms
40,240 KB
testcase_06 AC 133 ms
41,476 KB
testcase_07 AC 132 ms
41,020 KB
testcase_08 AC 132 ms
41,068 KB
testcase_09 AC 116 ms
39,932 KB
testcase_10 AC 129 ms
40,948 KB
testcase_11 AC 130 ms
41,532 KB
testcase_12 AC 127 ms
40,820 KB
testcase_13 AC 130 ms
41,252 KB
testcase_14 AC 131 ms
41,128 KB
testcase_15 AC 131 ms
40,968 KB
testcase_16 AC 133 ms
41,188 KB
testcase_17 AC 130 ms
41,264 KB
testcase_18 AC 126 ms
41,180 KB
testcase_19 AC 132 ms
41,340 KB
testcase_20 AC 115 ms
39,888 KB
testcase_21 AC 118 ms
40,092 KB
testcase_22 AC 129 ms
41,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
 	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int max = 0;
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if ((b > a && b > c && a != c) || (b < a && b < c && a != c)) {
		    System.out.println("INF");
		    return;
		}
		max = Math.max(max, a);
		max = Math.max(max, b);
		max = Math.max(max, c);
		int count = 0;
		for (int i = 3; i <= max; i++) {
		    int pa = a % i;
		    int pb = b % i;
		    int pc = c % i;
    		if ((pb > pa && pb > pc && pa != pc) || (pb < pa && pb < pc && pa != pc)) {
    		    count++;
    		}
		}
	    System.out.println(count);
	}
}
0