結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,280 KB
testcase_01 AC 136 ms
41,400 KB
testcase_02 AC 130 ms
41,436 KB
testcase_03 AC 132 ms
41,688 KB
testcase_04 AC 132 ms
41,516 KB
testcase_05 AC 137 ms
41,528 KB
testcase_06 AC 123 ms
40,016 KB
testcase_07 AC 140 ms
41,528 KB
testcase_08 AC 139 ms
41,564 KB
testcase_09 AC 138 ms
41,156 KB
testcase_10 AC 134 ms
41,032 KB
testcase_11 AC 123 ms
41,604 KB
testcase_12 AC 138 ms
41,536 KB
testcase_13 AC 138 ms
41,296 KB
testcase_14 AC 141 ms
41,448 KB
testcase_15 AC 137 ms
41,408 KB
testcase_16 AC 139 ms
41,664 KB
testcase_17 AC 138 ms
41,560 KB
testcase_18 AC 138 ms
41,524 KB
testcase_19 AC 135 ms
41,292 KB
testcase_20 AC 136 ms
41,308 KB
testcase_21 AC 134 ms
41,648 KB
testcase_22 AC 138 ms
41,432 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