結果

問題 No.887 Collatz
ユーザー watarimaycry2watarimaycry2
提出日時 2019-09-20 22:24:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 521 bytes
コンパイル時間 2,181 ms
コンパイル使用メモリ 76,524 KB
実行使用メモリ 57,132 KB
最終ジャッジ日時 2023-10-12 19:52:11
合計ジャッジ時間 8,945 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 165 ms
56,852 KB
testcase_01 AC 162 ms
56,960 KB
testcase_02 AC 164 ms
56,928 KB
testcase_03 AC 164 ms
56,880 KB
testcase_04 AC 164 ms
56,964 KB
testcase_05 AC 164 ms
56,836 KB
testcase_06 AC 165 ms
56,812 KB
testcase_07 AC 164 ms
56,780 KB
testcase_08 AC 161 ms
56,924 KB
testcase_09 AC 164 ms
56,852 KB
testcase_10 AC 163 ms
56,832 KB
testcase_11 AC 161 ms
56,968 KB
testcase_12 AC 164 ms
56,740 KB
testcase_13 AC 164 ms
56,824 KB
testcase_14 AC 163 ms
57,012 KB
testcase_15 AC 165 ms
56,852 KB
testcase_16 AC 164 ms
57,096 KB
testcase_17 AC 165 ms
56,568 KB
testcase_18 AC 165 ms
56,944 KB
testcase_19 AC 164 ms
56,596 KB
testcase_20 AC 167 ms
56,572 KB
testcase_21 AC 161 ms
56,824 KB
testcase_22 AC 162 ms
56,948 KB
testcase_23 AC 164 ms
56,784 KB
testcase_24 AC 164 ms
57,132 KB
testcase_25 AC 164 ms
56,888 KB
testcase_26 AC 167 ms
56,880 KB
testcase_27 AC 165 ms
56,904 KB
testcase_28 AC 167 ms
56,972 KB
testcase_29 AC 166 ms
56,980 KB
testcase_30 AC 165 ms
56,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class Main {
	public static void myout(Object text){//standard output
		System.out.println(text);
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
		Long n = sc.nextLong();
		Long m = n;
		int i = 0;
		while(n != 1){
		    if(n % 2 == 0){
		        n = n / 2;
		    }else{
		        n = 3 * n + 1;
		    }
		    i++;
		    m = Math.max(m,n);
		}
		myout(i + "\n" + m);
	}
}
0