結果

問題 No.2534 コラッツ数列
ユーザー kusagame12kusagame12
提出日時 2024-03-04 18:47:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 154 ms / 2,000 ms
コード長 681 bytes
コンパイル時間 2,167 ms
コンパイル使用メモリ 75,604 KB
実行使用メモリ 58,208 KB
最終ジャッジ日時 2024-03-04 18:47:44
合計ジャッジ時間 8,304 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
56,680 KB
testcase_01 AC 138 ms
57,772 KB
testcase_02 AC 136 ms
57,736 KB
testcase_03 AC 128 ms
56,920 KB
testcase_04 AC 140 ms
57,776 KB
testcase_05 AC 140 ms
57,768 KB
testcase_06 AC 154 ms
56,928 KB
testcase_07 AC 137 ms
57,772 KB
testcase_08 AC 139 ms
58,208 KB
testcase_09 AC 135 ms
57,696 KB
testcase_10 AC 140 ms
57,944 KB
testcase_11 AC 125 ms
57,576 KB
testcase_12 AC 123 ms
57,852 KB
testcase_13 AC 122 ms
57,528 KB
testcase_14 AC 123 ms
57,832 KB
testcase_15 AC 123 ms
57,576 KB
testcase_16 AC 138 ms
57,968 KB
testcase_17 AC 140 ms
57,668 KB
testcase_18 AC 152 ms
56,120 KB
testcase_19 AC 146 ms
57,576 KB
testcase_20 AC 124 ms
57,564 KB
testcase_21 AC 141 ms
57,940 KB
testcase_22 AC 143 ms
57,960 KB
testcase_23 AC 125 ms
56,684 KB
testcase_24 AC 139 ms
58,200 KB
testcase_25 AC 125 ms
57,696 KB
testcase_26 AC 127 ms
57,584 KB
testcase_27 AC 125 ms
58,072 KB
testcase_28 AC 145 ms
57,568 KB
testcase_29 AC 125 ms
57,816 KB
testcase_30 AC 141 ms
58,184 KB
testcase_31 AC 126 ms
57,804 KB
testcase_32 AC 144 ms
57,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
       
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
       
        int step = 1;
        int nn = N;
        while(step <= 50){
            
            step++;
            
            if(nn == 1){
                System.out.println("Yes\n"+step);
                return;
            }
            
            if(nn % 2 == 0){
                nn /= 2;
            }else{
                nn = 3 * nn + 1;
            }
            
            step++;
            
        }
      
        System.out.println("No");
        
    }
   
}
0