結果

問題 No.642 Two Operations No.1
ユーザー 🍮かんプリン
提出日時 2019-03-18 09:26:38
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 390 bytes
コンパイル時間 509 ms
コンパイル使用メモリ 63,604 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-17 22:49:45
合計ジャッジ時間 1,005 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>

using ll = long long;
using namespace std;

const int MOD = 1e9+7;

int main() {
    int n, cnt = 0;
    cin >> n;
    while(n != 1) {
        if (n % 2 == 0) {
            n /= 2;
        }
        else {
            n++;
        }
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}
0