結果

問題 No.358 も~っと!門松列
ユーザー Mcpu3Mcpu3
提出日時 2018-09-29 12:11:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 145 ms / 1,000 ms
コード長 1,095 bytes
コンパイル時間 2,264 ms
コンパイル使用メモリ 77,460 KB
実行使用メモリ 41,660 KB
最終ジャッジ日時 2024-04-20 12:49:50
合計ジャッジ時間 6,469 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
41,112 KB
testcase_01 AC 123 ms
40,288 KB
testcase_02 AC 138 ms
41,308 KB
testcase_03 AC 141 ms
41,356 KB
testcase_04 AC 138 ms
40,944 KB
testcase_05 AC 144 ms
41,140 KB
testcase_06 AC 142 ms
41,400 KB
testcase_07 AC 139 ms
41,208 KB
testcase_08 AC 139 ms
41,188 KB
testcase_09 AC 141 ms
41,212 KB
testcase_10 AC 140 ms
41,320 KB
testcase_11 AC 140 ms
41,284 KB
testcase_12 AC 140 ms
41,660 KB
testcase_13 AC 139 ms
41,160 KB
testcase_14 AC 145 ms
41,436 KB
testcase_15 AC 141 ms
41,412 KB
testcase_16 AC 137 ms
41,188 KB
testcase_17 AC 138 ms
41,380 KB
testcase_18 AC 139 ms
41,504 KB
testcase_19 AC 140 ms
41,272 KB
testcase_20 AC 140 ms
41,092 KB
testcase_21 AC 141 ms
41,080 KB
testcase_22 AC 138 ms
41,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A[] = new int[3], B[] = new int[3], ans = 0, minA = Integer.MAX_VALUE, maxA = Integer.MIN_VALUE, minB, maxB;
        for (int i = 0; i < 3; ++i) {
            A[i] = sc.nextInt();
            minA = Math.min(minA, A[i]);
            maxA = Math.max(maxA, A[i]);
        }
        sc.close();
        if (A[0] != A[1] && A[1] != A[2] && A[0] != A[2] && (A[1] == minA || A[1] == maxA)) System.out.print("INF");
        else {
            for (int i = 1; i <= maxA; ++i) {
                minB = Integer.MAX_VALUE;
                maxB = Integer.MIN_VALUE;
                for (int j = 0; j < 3; ++j) {
                    B[j] = A[j] % i;
                    minB = Math.min(minB, B[j]);
                    maxB = Math.max(maxB, B[j]);
                }
                if (B[0] != B[1] && B[1] != B[2] && B[0] != B[2] && (B[1] == minB || B[1] == maxB)) ++ans;
            }
            System.out.print(ans);
        }
    }
}
0