結果

問題 No.262 面白くないビットすごろく
ユーザー IL_mstaIL_msta
提出日時 2015-08-01 00:13:26
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,372 bytes
コンパイル時間 570 ms
コンパイル使用メモリ 85,316 KB
実行使用メモリ 7,628 KB
最終ジャッジ日時 2023-09-24 23:55:12
合計ジャッジ時間 4,040 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES
 
#include <iostream>
#include <iomanip>
#include <sstream>
 
#include <algorithm>
#include <cmath>
 
#include <string>
//#include <array>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>
#include <map>
 
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
 
#define PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////

LL bitcount(LL num){
	num = (num &0x5555555555555555) +(num>> 1 & 0x5555555555555555);
	num = (num &0x3333333333333333) +(num>> 2 & 0x3333333333333333);
	num = (num &0x0f0f0f0f0f0f0f0f) +(num>> 4 & 0x0f0f0f0f0f0f0f0f);
	num = (num &0x00ff00ff00ff00ff) +(num>> 8 & 0x00ff00ff00ff00ff);
	num = (num &0x0000ffff0000ffff) +(num>>16 & 0x0000ffff0000ffff);
	num = (num &0x00000000ffffffff) +(num>>32 & 0x00000000ffffffff);
	return num;
	/*int ans = 0;
	while(num){
		if(num%2 == 1)++ans;
		num /= 2;
	}
	return ans;*/
}
int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    cout << setprecision(16);//
	
	LL N;
	cin>>N;
	LL pos =  1;
	LL ans = 1;
	LL add;
	while(pos < N){
		add = bitcount(pos);
		pos += add;
		++ans;
		if( add == 0 ){
			break;
		}
	}
	if(pos == N){
		P(ans);
	}else{
		P(-1);
	}
	return 0;
}
0