結果

問題 No.262 面白くないビットすごろく
ユーザー fumofumofunifumofumofuni
提出日時 2021-04-18 18:44:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 472 ms / 2,000 ms
コード長 2,005 bytes
コンパイル時間 1,850 ms
コンパイル使用メモリ 200,920 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-17 07:59:59
合計ジャッジ時間 3,228 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=(n)-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,1,0,-1,1,-1,1,-1};
template <typename T> inline bool chmax(T &a, T b) {
  return ((a < b) ? (a = b, true) : (false));
}
template <typename T> inline bool chmin(T &a, T b) {
  return ((a > b) ? (a = b, true) : (false));
}
vl umecomi{
16528261375,
34179892637,
51804505761,
70213317069,
87953309938,
106520038461,
125404818570,
144194746393,
162286550795,
180935812837,
200148332580,
219130300531,
238637796475,
258381856246,
278235349289,
296108809336,
314691888318,
333733585567,
352860264736,
372090932249,
391799556548,
412459892513,
431052903006,
450613672574,
470565134403,
490705646259,
511049944011,
531830142929,
552577704794,
570404156594,
589004843649,
607996922408,
627194398350,
646369655949,
666056469887,
686688081834,
705362572698,
724885629032,
744795165468,
764984543942,
785241482314,
806016345293,
827085965369,
845924301194,
865519592653,
885658701687,
905672137367,
926210825894,
946936098999,
967834326487,
987983393422,
998367757387,
1008607909981,
};
int main(){
  ll n;cin >> n;
  ll k=1,cnt=0;
  rep(i,umecomi.size()){
    if(umecomi[i]<n){
      k=umecomi[i];cnt+=1000000000;
    }
  }
  if(k>=998367757387)cnt-=500000000;
  while(k<n){
    k+=__builtin_popcountl(k);
    cnt++;
  }
  if(k==n)cout << cnt+1 <<endl;
  else cout << -1 <<endl;
} 
0