結果

問題 No.887 Collatz
ユーザー KisaragiEffectiveKisaragiEffective
提出日時 2020-11-06 21:01:56
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 558 bytes
コンパイル時間 3,611 ms
コンパイル使用メモリ 78,488 KB
実行使用メモリ 56,712 KB
最終ジャッジ日時 2023-09-29 17:59:06
合計ジャッジ時間 9,687 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,960 KB
testcase_01 AC 127 ms
55,740 KB
testcase_02 AC 128 ms
56,628 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 126 ms
55,440 KB
testcase_06 AC 126 ms
56,320 KB
testcase_07 AC 127 ms
55,816 KB
testcase_08 AC 126 ms
56,220 KB
testcase_09 AC 128 ms
56,308 KB
testcase_10 AC 127 ms
56,076 KB
testcase_11 AC 126 ms
56,376 KB
testcase_12 AC 128 ms
56,216 KB
testcase_13 AC 127 ms
55,788 KB
testcase_14 AC 127 ms
55,912 KB
testcase_15 AC 126 ms
55,968 KB
testcase_16 AC 126 ms
55,828 KB
testcase_17 AC 126 ms
55,800 KB
testcase_18 AC 126 ms
56,032 KB
testcase_19 AC 127 ms
55,444 KB
testcase_20 AC 128 ms
55,936 KB
testcase_21 AC 127 ms
55,948 KB
testcase_22 AC 128 ms
56,220 KB
testcase_23 AC 127 ms
55,900 KB
testcase_24 AC 126 ms
55,480 KB
testcase_25 AC 131 ms
56,712 KB
testcase_26 AC 128 ms
55,908 KB
testcase_27 AC 126 ms
56,092 KB
testcase_28 AC 125 ms
56,056 KB
testcase_29 AC 125 ms
56,136 KB
testcase_30 AC 123 ms
56,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class x {
    public static void main(String[] args) {
        int[] xs = IntStream.iterate(
                new Scanner(System.in).nextInt(), p -> p % 2 == 0 ? p / 2 : 3 * p + 1
        )
                .limit(400L)
                .toArray();
        int index = 0;
        for (int x : xs) {
            if (x == 1) break;
            index++;
        }
        System.out.println(index);
        System.out.println(Arrays.stream(xs).max().getAsInt());
    }
}
0