結果

問題 No.857 素振り
ユーザー GodNegotoGodNegoto
提出日時 2019-11-07 15:39:17
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 456 bytes
コンパイル時間 5,616 ms
コンパイル使用メモリ 72,316 KB
実行使用メモリ 44,784 KB
最終ジャッジ日時 2023-10-13 03:01:23
合計ジャッジ時間 9,146 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
権限があれば一括ダウンロードができます

ソースコード

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