結果

問題 No.642 Two Operations No.1
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-03-06 14:15:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 310 bytes
コンパイル時間 3,053 ms
コンパイル使用メモリ 74,184 KB
実行使用メモリ 57,644 KB
最終ジャッジ日時 2023-10-19 01:44:44
合計ジャッジ時間 5,385 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
57,644 KB
testcase_01 AC 131 ms
57,448 KB
testcase_02 AC 130 ms
57,424 KB
testcase_03 AC 132 ms
57,480 KB
testcase_04 AC 134 ms
57,324 KB
testcase_05 AC 134 ms
57,556 KB
testcase_06 AC 132 ms
57,372 KB
testcase_07 AC 131 ms
57,408 KB
testcase_08 AC 131 ms
57,364 KB
testcase_09 AC 130 ms
57,404 KB
testcase_10 AC 130 ms
57,464 KB
testcase_11 AC 131 ms
57,064 KB
testcase_12 AC 130 ms
57,116 KB
testcase_13 AC 133 ms
57,340 KB
testcase_14 AC 130 ms
57,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import static java.lang.System.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int times = 0;
		while (1 < n) {
			if (n%2 == 1) {n++; times++;}
			else {n/=2; times++;}
		}
		out.println(times);
	}
}
0