結果

問題 No.642 Two Operations No.1
ユーザー oku_dan411oku_dan411
提出日時 2018-02-04 22:58:18
言語 C++11
(gcc 11.4.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 313 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 51,016 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-12 16:10:01
合計ジャッジ時間 2,767 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int check(int)’:
main.cpp:16:10: warning: control reaches end of non-void function [-Wreturn-type]
     check(n+1);
     ~~~~~^~~~~

ソースコード

diff #

#include <iostream>

using namespace std;

int a = 0;
int check(int n){
    while(1){
        if(n%2 == 0){
            n = n/2;
            a++;
        }
        else break;
    }
    if(n == 1)return a;
    a++;
    check(n+1);
}

int main()
{
    int N;
   cin >> N;
   cout << check(N) <<endl;
   return 0;
}
0