結果

問題 No.358 も~っと!門松列
ユーザー atkrym
提出日時 2016-10-19 11:51:27
言語 Java
(openjdk 23)
結果
AC  
実行時間 131 ms / 1,000 ms
コード長 737 bytes
コンパイル時間 2,500 ms
コンパイル使用メモリ 74,700 KB
実行使用メモリ 41,492 KB
最終ジャッジ日時 2024-11-22 15:07:24
合計ジャッジ時間 6,402 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

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