結果

問題 No.642 Two Operations No.1
ユーザー lunnear
提出日時 2018-11-21 11:44:27
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 287 bytes
コンパイル時間 493 ms
コンパイル使用メモリ 53,856 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 16:00:39
合計ジャッジ時間 1,112 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

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