結果

問題 No.642 Two Operations No.1
ユーザー kwkm0429kwkm0429
提出日時 2018-02-02 22:32:55
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 589 bytes
コンパイル時間 1,591 ms
コンパイル使用メモリ 143,328 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-30 02:19:02
合計ジャッジ時間 2,205 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define EPS (1e-7)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};
int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;

int main(){
	int n;
	cin>>n;
	int k=0;
	while(n%2==0){
		k++;
		n/=2;
	}
	int s=0,i=1;
	while(i<n){
		s++;
		i*=2;
	}
	int res=i-n+s+k;
	cout<<res<<endl;
	return 0;
}
0