結果

問題 No.358 も~っと!門松列
ユーザー tenten
提出日時 2021-02-10 08:44:30
言語 Java
(openjdk 23)
結果
AC  
実行時間 105 ms / 1,000 ms
コード長 695 bytes
コンパイル時間 1,719 ms
コンパイル使用メモリ 77,348 KB
実行使用メモリ 41,224 KB
最終ジャッジ日時 2024-07-07 18:40:27
合計ジャッジ時間 4,924 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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