結果

問題 No.857 素振り
ユーザー GodNegoto
提出日時 2019-11-07 15:39:17
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 456 bytes
コンパイル時間 3,239 ms
コンパイル使用メモリ 74,264 KB
実行使用メモリ 46,844 KB
最終ジャッジ日時 2024-09-15 00:41:28
合計ジャッジ時間 6,362 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other WA * 2 TLE * 1 -- * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

package algo;

import java.util.Scanner;

//import algo.*;

public class sample7 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int cnt = 0;
		int max = n;
		while (n != 1) {
			if(n % 2 == 0) {
				n = n / 2;
				
			}
			else {
				n = 3 * n + 1;
			}
			cnt++;
			max = Math.max(max, n);
		}
		System.out.println(cnt);	
		System.out.println(max);
	}
}

0