結果

問題 No.358 も~っと!門松列
ユーザー sasukesasuke
提出日時 2016-06-17 03:20:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 140 ms / 1,000 ms
コード長 791 bytes
コンパイル時間 2,216 ms
コンパイル使用メモリ 78,052 KB
実行使用メモリ 41,928 KB
最終ジャッジ日時 2024-04-17 23:04:32
合計ジャッジ時間 6,225 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
41,072 KB
testcase_01 AC 138 ms
41,496 KB
testcase_02 AC 132 ms
41,428 KB
testcase_03 AC 136 ms
41,928 KB
testcase_04 AC 136 ms
41,400 KB
testcase_05 AC 134 ms
41,164 KB
testcase_06 AC 133 ms
41,424 KB
testcase_07 AC 136 ms
41,560 KB
testcase_08 AC 134 ms
41,356 KB
testcase_09 AC 137 ms
41,444 KB
testcase_10 AC 140 ms
41,612 KB
testcase_11 AC 135 ms
41,564 KB
testcase_12 AC 134 ms
41,268 KB
testcase_13 AC 136 ms
41,104 KB
testcase_14 AC 136 ms
41,568 KB
testcase_15 AC 135 ms
41,488 KB
testcase_16 AC 135 ms
41,456 KB
testcase_17 AC 139 ms
41,428 KB
testcase_18 AC 134 ms
41,428 KB
testcase_19 AC 138 ms
41,484 KB
testcase_20 AC 138 ms
41,304 KB
testcase_21 AC 136 ms
40,944 KB
testcase_22 AC 136 ms
41,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a1 = sc.nextInt();
        long a2 = sc.nextInt();
        long a3 = sc.nextInt();
        long Max=Math.max(Math.max(a1,a2),a3);
        int count =0;
        if(((a1!=a2)&&(a2!=a3)&&(a3!=a1))&&(((a2>a1)&&(a2>a3))||((a2<a1)&&(a2<a3)))){
            System.out.println("INF");
        }else{
            for(int i=1;i<=Max;i++){
                long b1=a1%i;
                long b2=a2%i;
                long b3=a3%i;
                if(((b1!=b2)&&(b2!=b3)&&(b3!=b1))&&(((b2>b1)&&(b2>b3))||((b2<b1)&&(b2<b3)))){
                   count++;
                }     
            }
            System.out.println(count);         
        }
    }
}
0