結果

問題 No.358 も~っと!門松列
ユーザー sasukesasuke
提出日時 2016-06-17 03:32:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 1,000 ms
コード長 786 bytes
コンパイル時間 1,818 ms
コンパイル使用メモリ 74,848 KB
実行使用メモリ 54,428 KB
最終ジャッジ日時 2024-04-17 23:05:03
合計ジャッジ時間 5,286 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
52,992 KB
testcase_01 AC 107 ms
52,984 KB
testcase_02 AC 119 ms
54,160 KB
testcase_03 AC 116 ms
54,124 KB
testcase_04 AC 109 ms
53,740 KB
testcase_05 AC 108 ms
53,140 KB
testcase_06 AC 118 ms
54,156 KB
testcase_07 AC 117 ms
54,120 KB
testcase_08 AC 103 ms
53,028 KB
testcase_09 AC 121 ms
54,260 KB
testcase_10 AC 113 ms
54,176 KB
testcase_11 AC 117 ms
54,224 KB
testcase_12 AC 117 ms
54,280 KB
testcase_13 AC 124 ms
54,144 KB
testcase_14 AC 121 ms
54,196 KB
testcase_15 AC 120 ms
54,092 KB
testcase_16 AC 115 ms
53,996 KB
testcase_17 AC 126 ms
54,428 KB
testcase_18 AC 115 ms
54,176 KB
testcase_19 AC 114 ms
54,144 KB
testcase_20 AC 108 ms
53,488 KB
testcase_21 AC 134 ms
54,140 KB
testcase_22 AC 122 ms
53,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

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();
        int 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++){
                int b1=a1%i;
                int b2=a2%i;
                int b3=a3%i;
                if(kado(b1,b2,b3)){
                   count++;
                }     
            }
            System.out.println(count);         
        }
    }
    public static boolean kado(int x,int y,int z){
        return (x!=y&&y!=z&&z!=x)&&((y>x&&y>z)||(y<x&&y<z));
    }
}
0