結果

問題 No.642 Two Operations No.1
ユーザー ミドリムシミドリムシ
提出日時 2018-02-02 21:33:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 375 bytes
コンパイル時間 552 ms
コンパイル使用メモリ 69,220 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-10 01:11:21
合計ジャッジ時間 1,170 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    long N;
    cin >> N;
    long times_num = 1;
    long ans = 0;
    for(; times_num < N; times_num *= 2){
        ans++;
    }
    for(int i = 1; i < 50; i++){
        if(((times_num - N) >> i) & 1){
            ans--;
        }
    }
    cout << ans + times_num - N << endl;
}
0