結果

問題 No.642 Two Operations No.1
ユーザー suakii
提出日時 2018-06-05 18:13:22
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 426 bytes
コンパイル時間 1,252 ms
コンパイル使用メモリ 159,612 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-30 09:58:41
合計ジャッジ時間 1,865 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;

int n, ans;

bool f(int k) {
    int val = (int)(log2(k));
    
    return ((int)pow(2, val)) == k;
    
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n;
    if (f(n)) {
        cout << (int)(log2(n)) << endl;
    } else {
        cout << (int)(log2(n)) + 1 + (int)pow(2,(int)(log2(n))+1) - n << endl;
    }
    

}

0