結果

問題 No.358 も~っと!門松列
ユーザー yun_appyun_app
提出日時 2016-05-10 22:21:39
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,243 bytes
コンパイル時間 2,327 ms
コンパイル使用メモリ 76,904 KB
実行使用メモリ 37,220 KB
最終ジャッジ日時 2024-04-15 15:07:20
合計ジャッジ時間 4,313 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
37,064 KB
testcase_01 AC 55 ms
37,008 KB
testcase_02 AC 52 ms
37,092 KB
testcase_03 AC 56 ms
36,996 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 52 ms
36,884 KB
testcase_07 WA -
testcase_08 AC 52 ms
36,988 KB
testcase_09 WA -
testcase_10 AC 53 ms
37,080 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 53 ms
36,992 KB
testcase_14 AC 54 ms
36,724 KB
testcase_15 AC 55 ms
37,156 KB
testcase_16 AC 54 ms
37,008 KB
testcase_17 AC 53 ms
37,028 KB
testcase_18 AC 53 ms
37,004 KB
testcase_19 AC 55 ms
37,080 KB
testcase_20 WA -
testcase_21 AC 55 ms
37,068 KB
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] lines = br.readLine().split(" ");
        int a1 = Integer.parseInt(lines[0]);
        int a2 = Integer.parseInt(lines[1]);
        int a3 = Integer.parseInt(lines[2]);
        
        if(a1 == a2 || a1 == a3 || a2 == a3){
            System.out.println("0");
            return;
        }
        if((a2 < a1 && a2 < a3) || (a2 > a1 && a2 > a3)){
            System.out.println("INF");
            return;
        }
        
        int max = Math.max(Math.max(a1,a2),a3);
        int ans = 0;
        for(int i=1;i<=max;i++){
            if(check(a1%i,a2%i,a3%i)){
                ++ans;
            }
        }
        System.out.println(ans);
    }
    public static boolean check(int a1,int a2,int a3){
        return  (a1 != a3) && (a2 != a3) && (a1 != a2) && 
                (a2 < a1 && a2 < a3) || (a2 > a1 && a2 > a3);
    }

}
0