結果

問題 No.642 Two Operations No.1
ユーザー tetsuzuki1115tetsuzuki1115
提出日時 2018-02-03 12:31:58
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 634 bytes
コンパイル時間 1,816 ms
コンパイル使用メモリ 72,496 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-02 08:25:05
合計ジャッジ時間 1,685 ms
ジャッジサーバーID
(参考情報)
judge16 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 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
4,376 KB
testcase_14 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    long long N;
    cin >> N;
    
    long long n = N;
    long long a = 0;
    while ( n%2 == 0 ) {
        n /= 2;
        a++;
    }
    
    long long ans = 0;
    long long x = 1;
    while ( x < n ) {
        x *= 2;
        ans++;
    }
    ans += x-n;
    ans += a;
    
    cout << ans << endl;
    
    return 0;
}
0