結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
37,128 KB
testcase_01 AC 57 ms
36,916 KB
testcase_02 AC 57 ms
36,580 KB
testcase_03 AC 53 ms
37,068 KB
testcase_04 AC 56 ms
36,536 KB
testcase_05 AC 55 ms
37,108 KB
testcase_06 AC 55 ms
37,108 KB
testcase_07 AC 56 ms
37,236 KB
testcase_08 AC 54 ms
37,008 KB
testcase_09 AC 56 ms
37,124 KB
testcase_10 AC 56 ms
37,048 KB
testcase_11 AC 54 ms
37,256 KB
testcase_12 AC 54 ms
36,876 KB
testcase_13 AC 54 ms
36,844 KB
testcase_14 AC 56 ms
36,992 KB
testcase_15 AC 56 ms
37,260 KB
testcase_16 AC 53 ms
37,124 KB
testcase_17 AC 57 ms
37,012 KB
testcase_18 AC 54 ms
37,140 KB
testcase_19 AC 55 ms
36,984 KB
testcase_20 AC 54 ms
36,960 KB
testcase_21 AC 55 ms
37,124 KB
testcase_22 AC 53 ms
37,012 KB
権限があれば一括ダウンロードができます

ソースコード

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