結果

問題 No.642 Two Operations No.1
ユーザー kichirb3
提出日時 2018-03-07 08:12:48
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 464 bytes
コンパイル時間 542 ms
コンパイル使用メモリ 64,192 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-24 13:40:47
合計ジャッジ時間 1,306 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

// No.642 Two Operations No.1
// https://yukicoder.me/problems/no/642a
//
#include <iostream>
using namespace std;

int solve(int N);


int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int N;
    cin >> N;
    int ans = solve(N);
    cout << ans << endl;
}


int solve(int N) {
    int ans = 0;

    while (N != 1) {
        if (N % 2 == 0)
            N /= 2;
        else
            ++N;
        ++ans;
    }
    return ans;
}
0