結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
41,100 KB
testcase_01 AC 134 ms
41,344 KB
testcase_02 AC 135 ms
41,296 KB
testcase_03 AC 120 ms
40,268 KB
testcase_04 AC 134 ms
41,344 KB
testcase_05 AC 134 ms
41,244 KB
testcase_06 AC 132 ms
41,132 KB
testcase_07 AC 133 ms
41,300 KB
testcase_08 AC 134 ms
41,312 KB
testcase_09 AC 135 ms
41,536 KB
testcase_10 AC 135 ms
41,164 KB
testcase_11 AC 134 ms
41,716 KB
testcase_12 AC 135 ms
41,276 KB
testcase_13 AC 132 ms
41,808 KB
testcase_14 AC 130 ms
41,400 KB
testcase_15 AC 129 ms
41,176 KB
testcase_16 AC 134 ms
41,404 KB
testcase_17 AC 134 ms
41,120 KB
testcase_18 AC 133 ms
41,580 KB
testcase_19 AC 133 ms
41,500 KB
testcase_20 AC 132 ms
41,660 KB
testcase_21 AC 133 ms
41,332 KB
testcase_22 AC 134 ms
41,692 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(kado(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(kado(b1,b2,b3)){
                   count++;
                }     
            }
            System.out.println(count);         
        }
    }
    public static boolean kado(long x,long y,long z){
        return (x!=y&&y!=z&&z!=x)&&((y>x&&y>z)||(y<x&&y<z));
    }
}
0