結果

問題 No.887 Collatz
ユーザー tentententen
提出日時 2020-08-30 22:07:01
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 526 bytes
コンパイル時間 2,249 ms
コンパイル使用メモリ 74,636 KB
実行使用メモリ 55,972 KB
最終ジャッジ日時 2024-04-27 13:30:13
合計ジャッジ時間 6,972 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
54,360 KB
testcase_01 AC 127 ms
54,324 KB
testcase_02 AC 126 ms
53,864 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 126 ms
54,036 KB
testcase_06 AC 125 ms
54,440 KB
testcase_07 AC 125 ms
54,096 KB
testcase_08 AC 124 ms
53,924 KB
testcase_09 AC 107 ms
53,100 KB
testcase_10 AC 128 ms
53,944 KB
testcase_11 AC 128 ms
54,136 KB
testcase_12 AC 133 ms
54,156 KB
testcase_13 AC 126 ms
54,364 KB
testcase_14 AC 121 ms
54,092 KB
testcase_15 AC 125 ms
54,008 KB
testcase_16 AC 128 ms
54,136 KB
testcase_17 AC 110 ms
52,896 KB
testcase_18 AC 113 ms
53,176 KB
testcase_19 AC 128 ms
54,052 KB
testcase_20 AC 126 ms
55,972 KB
testcase_21 AC 124 ms
54,208 KB
testcase_22 AC 130 ms
54,100 KB
testcase_23 AC 127 ms
54,224 KB
testcase_24 AC 129 ms
53,848 KB
testcase_25 AC 126 ms
54,176 KB
testcase_26 AC 137 ms
54,096 KB
testcase_27 AC 127 ms
54,292 KB
testcase_28 AC 121 ms
53,964 KB
testcase_29 AC 129 ms
53,956 KB
testcase_30 AC 133 ms
54,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int max = 0;
    	int min = Integer.MAX_VALUE;
    	for (int i = 0; i < 400; i++) {
    	    if (n == 1) {
    	        min = Math.min(min, i);
    	    }
    	    max = Math.max(max, n);
    	    if (n % 2 == 0) {
    	        n /= 2;
    	    } else {
    	        n = 3 * n + 1;
    	    }
    	}
    	System.out.println(min);
    	System.out.println(max);
    }
}
0