結果

問題 No.358 も~っと!門松列
ユーザー yagi2yagi2
提出日時 2017-04-17 16:52:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 1,000 ms
コード長 1,023 bytes
コンパイル時間 4,304 ms
コンパイル使用メモリ 75,752 KB
実行使用メモリ 56,344 KB
最終ジャッジ日時 2023-09-26 10:46:59
合計ジャッジ時間 6,720 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
56,344 KB
testcase_01 AC 127 ms
55,484 KB
testcase_02 AC 128 ms
55,740 KB
testcase_03 AC 129 ms
53,788 KB
testcase_04 AC 128 ms
55,572 KB
testcase_05 AC 129 ms
55,884 KB
testcase_06 AC 129 ms
55,584 KB
testcase_07 AC 130 ms
56,104 KB
testcase_08 AC 129 ms
55,316 KB
testcase_09 AC 131 ms
55,904 KB
testcase_10 AC 129 ms
55,576 KB
testcase_11 AC 131 ms
55,352 KB
testcase_12 AC 130 ms
55,760 KB
testcase_13 AC 130 ms
55,888 KB
testcase_14 AC 129 ms
55,568 KB
testcase_15 AC 131 ms
55,756 KB
testcase_16 AC 130 ms
55,364 KB
testcase_17 AC 131 ms
55,708 KB
testcase_18 AC 131 ms
55,608 KB
testcase_19 AC 134 ms
55,668 KB
testcase_20 AC 130 ms
55,584 KB
testcase_21 AC 129 ms
55,868 KB
testcase_22 AC 131 ms
55,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        List<Integer> A = new ArrayList<>();
        for (int i = 0; i < 3; i ++) {
            A.add(Integer.parseInt(sc.next()));
        }

        int cnt = 0;
        for (int i = 3; i <= 2000; i ++) {
            List<Integer> T = new ArrayList<>();
            T.add(A.get(0) % i);
            T.add(A.get(1) % i);
            T.add(A.get(2) % i);

            if (isKadomatsu(T)) cnt++;
        }

        if (cnt >= 1000) {
            System.out.println("INF");
        } else {
            System.out.println(cnt);
        }
    }

    private static boolean isKadomatsu(List<Integer> A) {
        List<Integer> T = new ArrayList<>(A);

        return ((!Objects.equals(T.get(0), T.get(2)))&&((T.get(1) < T.get(0) && T.get(1) < T.get(2)) || (T.get(1) > T.get(0) && T.get(1) > T.get(2))));
    }
}
0