結果

問題 No.358 も~っと!門松列
ユーザー atkrymatkrym
提出日時 2016-10-19 11:51:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 115 ms / 1,000 ms
コード長 737 bytes
コンパイル時間 2,302 ms
コンパイル使用メモリ 74,752 KB
実行使用メモリ 41,580 KB
最終ジャッジ日時 2024-05-02 04:33:17
合計ジャッジ時間 4,956 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
40,924 KB
testcase_01 AC 111 ms
41,096 KB
testcase_02 AC 105 ms
41,580 KB
testcase_03 AC 106 ms
41,280 KB
testcase_04 AC 106 ms
41,108 KB
testcase_05 AC 115 ms
41,028 KB
testcase_06 AC 105 ms
41,016 KB
testcase_07 AC 99 ms
40,004 KB
testcase_08 AC 101 ms
40,060 KB
testcase_09 AC 97 ms
40,240 KB
testcase_10 AC 98 ms
39,896 KB
testcase_11 AC 107 ms
41,040 KB
testcase_12 AC 98 ms
40,008 KB
testcase_13 AC 105 ms
41,492 KB
testcase_14 AC 108 ms
40,900 KB
testcase_15 AC 106 ms
41,260 KB
testcase_16 AC 95 ms
39,348 KB
testcase_17 AC 106 ms
40,944 KB
testcase_18 AC 107 ms
41,212 KB
testcase_19 AC 103 ms
40,904 KB
testcase_20 AC 104 ms
41,028 KB
testcase_21 AC 104 ms
41,200 KB
testcase_22 AC 106 ms
41,484 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