結果

問題 No.358 も~っと!門松列
ユーザー atkrymatkrym
提出日時 2016-10-19 11:51:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 118 ms / 1,000 ms
コード長 737 bytes
コンパイル時間 2,037 ms
コンパイル使用メモリ 71,492 KB
実行使用メモリ 40,148 KB
最終ジャッジ日時 2023-08-14 16:27:12
合計ジャッジ時間 5,760 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
39,296 KB
testcase_01 AC 118 ms
39,344 KB
testcase_02 AC 117 ms
39,216 KB
testcase_03 AC 117 ms
39,664 KB
testcase_04 AC 116 ms
39,100 KB
testcase_05 AC 118 ms
39,032 KB
testcase_06 AC 115 ms
39,684 KB
testcase_07 AC 115 ms
39,060 KB
testcase_08 AC 115 ms
39,632 KB
testcase_09 AC 116 ms
39,540 KB
testcase_10 AC 116 ms
39,736 KB
testcase_11 AC 116 ms
39,336 KB
testcase_12 AC 118 ms
39,232 KB
testcase_13 AC 114 ms
40,148 KB
testcase_14 AC 115 ms
39,280 KB
testcase_15 AC 115 ms
39,172 KB
testcase_16 AC 115 ms
39,228 KB
testcase_17 AC 114 ms
39,540 KB
testcase_18 AC 113 ms
39,228 KB
testcase_19 AC 113 ms
39,060 KB
testcase_20 AC 116 ms
39,704 KB
testcase_21 AC 114 ms
39,100 KB
testcase_22 AC 116 ms
39,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if (isKadomatsu(a, b, c)) {
            System.out.println("INF");
            return;
        }
        
        int max = Math.max(Math.max(a, b), c);
        
        int ret = 0;
        for (int i = 1;i <= max;i++) {
            if (isKadomatsu(a%i, b%i, c%i)) ret++;
        }
        
        System.out.println(ret);
    }
    
    private static boolean isKadomatsu(int a, int b, int c) {
        return a != c && ((a < b && c < b) || (a > b && c > b));
    }
}
0