結果

問題 No.884 Eat and Add
コンテスト
ユーザー vjudge1
提出日時 2026-09-19 10:35:42
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 287 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,011 ms
コンパイル使用メモリ 179,456 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2026-09-19 10:35:49
合計ジャッジ時間 6,042 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2 TLE * 1
other -- * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin >> n;
    int c = 0;
    while(n){
        if(n & 1){
            if((n & 3) == 3 && n > 3) n++;
            else n--;
            c++;
        } else n >>= 1;
    }
    cout << c << endl;
    return 0;
}
0