結果

問題 No.642 Two Operations No.1
コンテスト
ユーザー denderaKawazu
提出日時 2018-02-13 20:08:20
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 980 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,232 ms
コンパイル使用メモリ 82,488 KB
実行使用メモリ 47,352 KB
最終ジャッジ日時 2026-05-24 00:12:22
合計ジャッジ時間 5,605 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int count = 0;
            while (n != 1) {
                if ((n & 1) == 1) {
                    n++;
                } else {
                    n /= 2;
                }
                count++;
            }
            out.println(count);
        }

    }
}

0