結果

問題 No.887 Collatz
ユーザー iwa_choco_168iwa_choco_168
提出日時 2019-12-02 13:31:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 450 bytes
コンパイル時間 1,696 ms
コンパイル使用メモリ 71,632 KB
実行使用メモリ 56,428 KB
最終ジャッジ日時 2023-08-15 18:53:02
合計ジャッジ時間 7,058 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
55,200 KB
testcase_01 AC 104 ms
56,320 KB
testcase_02 AC 105 ms
56,428 KB
testcase_03 AC 103 ms
55,932 KB
testcase_04 AC 101 ms
55,612 KB
testcase_05 AC 102 ms
55,848 KB
testcase_06 AC 104 ms
55,348 KB
testcase_07 AC 103 ms
55,572 KB
testcase_08 AC 105 ms
55,348 KB
testcase_09 AC 101 ms
55,532 KB
testcase_10 AC 103 ms
55,320 KB
testcase_11 AC 102 ms
55,136 KB
testcase_12 AC 103 ms
55,556 KB
testcase_13 AC 102 ms
55,588 KB
testcase_14 AC 102 ms
55,740 KB
testcase_15 AC 107 ms
55,872 KB
testcase_16 AC 103 ms
55,816 KB
testcase_17 AC 104 ms
55,452 KB
testcase_18 AC 105 ms
55,660 KB
testcase_19 AC 105 ms
55,384 KB
testcase_20 AC 105 ms
55,748 KB
testcase_21 AC 105 ms
55,412 KB
testcase_22 AC 100 ms
55,708 KB
testcase_23 AC 103 ms
55,844 KB
testcase_24 AC 103 ms
55,868 KB
testcase_25 AC 102 ms
55,600 KB
testcase_26 AC 108 ms
55,800 KB
testcase_27 AC 102 ms
55,544 KB
testcase_28 AC 101 ms
55,376 KB
testcase_29 AC 106 ms
55,612 KB
testcase_30 AC 101 ms
55,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int max = n;
        int count = 0;
        while(n != 1) {
            count++;
            if(n % 2 == 0) n /= 2;
            else n = 3 * n + 1;
            if(max < n) max = n;
        }
        System.out.println(count);
        System.out.println(max);
    }
}
0