結果

問題 No.358 も~っと!門松列
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-11 03:31:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 110 ms / 1,000 ms
コード長 1,003 bytes
コンパイル時間 2,212 ms
コンパイル使用メモリ 72,192 KB
実行使用メモリ 58,292 KB
最終ジャッジ日時 2023-08-16 18:11:16
合計ジャッジ時間 5,158 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
56,164 KB
testcase_01 AC 109 ms
56,160 KB
testcase_02 AC 110 ms
55,856 KB
testcase_03 AC 108 ms
56,112 KB
testcase_04 AC 102 ms
55,840 KB
testcase_05 AC 105 ms
56,180 KB
testcase_06 AC 104 ms
56,232 KB
testcase_07 AC 106 ms
56,172 KB
testcase_08 AC 105 ms
55,972 KB
testcase_09 AC 104 ms
55,996 KB
testcase_10 AC 108 ms
58,292 KB
testcase_11 AC 105 ms
56,100 KB
testcase_12 AC 104 ms
56,416 KB
testcase_13 AC 108 ms
56,400 KB
testcase_14 AC 104 ms
56,176 KB
testcase_15 AC 108 ms
55,852 KB
testcase_16 AC 102 ms
54,320 KB
testcase_17 AC 104 ms
56,108 KB
testcase_18 AC 106 ms
56,040 KB
testcase_19 AC 108 ms
55,948 KB
testcase_20 AC 106 ms
55,704 KB
testcase_21 AC 106 ms
56,296 KB
testcase_22 AC 104 ms
56,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A1 = sc.nextInt();
        int A2 = sc.nextInt();
        int A3 = sc.nextInt();
        if(A1!=A2 && A1!=A3 && A2!=A3){
            if( (A2>A1 && A2>A3) || (A2<A1 && A2<A3) ){
                System.out.println("INF");
            }else{
                int max = Math.max(Math.max(A1,A2),A3) ;
                int c = 0;
                int p = 2;
                while(true){
                    int a1 = A1%p;
                    int a2 = A2%p;
                    int a3 = A3%p;
                    if( ( (a2>a1 && a2>a3) || (a2<a1 && a2<a3) ) && a1!=a3 ){
                        c++;
                    }
                    p++;
                    if(p>max){
                        break;
                    }
                }
                System.out.println(c);
            }
        }else{
            System.out.println(0);
        }
    }
}
0