結果

問題 No.358 も~っと!門松列
ユーザー jp_stejp_ste
提出日時 2016-05-05 17:45:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 140 ms / 1,000 ms
コード長 1,033 bytes
コンパイル時間 2,327 ms
コンパイル使用メモリ 74,552 KB
実行使用メモリ 42,196 KB
最終ジャッジ日時 2024-04-15 13:22:05
合計ジャッジ時間 6,904 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
41,744 KB
testcase_01 AC 130 ms
41,948 KB
testcase_02 AC 134 ms
41,316 KB
testcase_03 AC 130 ms
41,256 KB
testcase_04 AC 137 ms
41,956 KB
testcase_05 AC 135 ms
42,076 KB
testcase_06 AC 137 ms
41,296 KB
testcase_07 AC 134 ms
41,916 KB
testcase_08 AC 140 ms
41,288 KB
testcase_09 AC 135 ms
41,932 KB
testcase_10 AC 135 ms
41,948 KB
testcase_11 AC 135 ms
41,388 KB
testcase_12 AC 134 ms
41,760 KB
testcase_13 AC 133 ms
41,464 KB
testcase_14 AC 135 ms
41,812 KB
testcase_15 AC 138 ms
41,848 KB
testcase_16 AC 136 ms
41,888 KB
testcase_17 AC 138 ms
41,864 KB
testcase_18 AC 136 ms
41,568 KB
testcase_19 AC 139 ms
41,816 KB
testcase_20 AC 134 ms
41,356 KB
testcase_21 AC 134 ms
42,196 KB
testcase_22 AC 136 ms
41,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner scan = new Scanner(System.in)) {
            int a1 = scan.nextInt();
            int a2 = scan.nextInt();
            int a3 = scan.nextInt();
            if(isKadomathu(a1, a2, a3)) {
                System.out.println("INF");
            } else {
                
                int max = a1;
                if(max < a2) max = a2;
                if(max < a3) max = a3;
                
                int ans = 0;
                for(int p=2; p<=max; p++) {
                    if(isKadomathu(a1%p, a2%p, a3%p)) {
                        ans++;
                    }
                }
                System.out.println(ans);
            }
        }
    }
    
    static boolean isKadomathu(int v1, int v2, int v3) {
        if(v1 != v2 && v1 != v3 && v2 != v3) {
            if((v2 > v1 && v2 > v3) || (v2 < v1 && v2 < v3)) {
                return true;
            }   
        }
        return false;
    }
}
0