結果

問題 No.358 も~っと!門松列
ユーザー kohaku_kohaku
提出日時 2016-11-11 03:31:06
言語 Java
(openjdk 23)
結果
AC  
実行時間 132 ms / 1,000 ms
コード長 1,003 bytes
コンパイル時間 2,121 ms
コンパイル使用メモリ 74,708 KB
実行使用メモリ 43,296 KB
最終ジャッジ日時 2024-11-25 07:40:00
合計ジャッジ時間 5,923 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

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