結果

問題 No.642 Two Operations No.1
ユーザー uafr_csuafr_cs
提出日時 2018-02-02 21:28:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 383 bytes
コンパイル時間 2,054 ms
コンパイル使用メモリ 71,988 KB
実行使用メモリ 56,212 KB
最終ジャッジ日時 2023-08-30 01:59:57
合計ジャッジ時間 4,900 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,472 KB
testcase_01 AC 124 ms
55,720 KB
testcase_02 AC 124 ms
53,740 KB
testcase_03 AC 124 ms
56,056 KB
testcase_04 AC 122 ms
55,632 KB
testcase_05 AC 120 ms
55,892 KB
testcase_06 AC 122 ms
54,740 KB
testcase_07 AC 122 ms
55,796 KB
testcase_08 AC 122 ms
55,724 KB
testcase_09 AC 120 ms
56,212 KB
testcase_10 AC 121 ms
55,688 KB
testcase_11 AC 122 ms
55,964 KB
testcase_12 AC 125 ms
55,828 KB
testcase_13 AC 123 ms
56,064 KB
testcase_14 AC 120 ms
56,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final long N = sc.nextLong();
		
		int count = 0;
		long x = N;
		while(x != 1){
			if(x % 2 == 0){
				x /= 2; count++;
			}else{
				x++; count++;
			}
		}
		
		System.out.println(count);
	}
}
0