結果

問題 No.262 面白くないビットすごろく
ユーザー r_dream0r_dream0
提出日時 2017-02-09 15:52:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,043 ms / 2,000 ms
コード長 4,470 bytes
コンパイル時間 650 ms
コンパイル使用メモリ 71,552 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-07 18:00:19
合計ジャッジ時間 3,833 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector<int64_t> answer = {3043866194LL,6304910356LL,9642632542LL,13027785723LL,16528261358LL,19866093995LL,23305273520LL,26851772357LL,30427698850LL,34179892617LL,37474898914LL,40939570388LL,44462028961LL,48061009280LL,51804505746LL,55324780514LL,59013445723LL,62731107711LL,66594902230LL,70213317053LL,73611431518LL,77182126867LL,80667255466LL,84337635794LL,87953309922LL,91556662124LL,95303593650LL,99080204098LL,103042167164LL,106520038443LL,110194551888LL,113932646949LL,117756428320LL,121611143221LL,125404818549LL,129354551798LL,133318905954LL,137462808107LL,140732668131LL,144194746378LL,147724195489LL,151331584259LL,155051645104LL,158596635922LL,162286550775LL,166003338810LL,169866379974LL,173576727157LL,177188326745LL,180935812820LL,184711441692LL,188617425837LL,192340450167LL,196219122498LL,200148332563LL,204206289190LL,207999147165LL,211606934829LL,215354169160LL,219130300515LL,223051245640LL,226765329931LL,230647419390LL,234578074818LL,238637796451LL,242543758152LL,246354023479LL,250293791169LL,254282368786LL,258381856228LL,262353169338LL,266499308715LL,270653190645LL,274954969314LL,278235349275LL,281699656501LL,285230291468LL,288843338514LL,292555622117LL,296108809315LL,299797478086LL,303513296406LL,307378730096LL,311084691327LL,314691888304LL,318438834114LL,322215373216LL,326137829776LL,329850743215LL,333733585550LL,337664008995LL,341723231844LL,345507238647LL,349113030826LL,352860264722LL,356636401269LL,360569937165LL,364277970837LL,368164629305LL,372090932234LL,376151464681LL,380058390854LL,383870119622LL,387803833086LL,391799556527LL,395892667645LL,399867029795LL,404011963590LL,408166458636LL,412459892498LL,415960418149LL,419642241630LL,423369329072LL,427219090665LL,431052902989LL,434863107881LL,438796401965LL,442769590804LL,446887863671LL,450613672551LL,454512303678LL,458440607813LL,462516131457LL,466505438561LL,470565134382LL,474703374216LL,478949396271LL,482947439044LL,486755371530LL,490705646242LL,494681424767LL,498791098608LL,502758835063LL,506906580522LL,511049943986LL,515389888625LL,519289749354LL,523399099775LL,527525826896LL,531830142902LL,535991669344LL,540290279115LL,544627454197LL,549136811489LL,552577704779LL,556033975597LL,559563840946LL,563154351826LL,566933008696LL,570404156573LL,574077826778LL,577815644698LL,581642857002LL,585412682625LL,589004843632LL,592776838342LL,596480632577LL,600373164682LL,604131558044LL,607996922389LL,611936152771LL,615953831149LL,619832855764LL,623425191186LL,627194398336LL,630905954525LL,634802011533LL,638556986920LL,642421663973LL,646369655928LL,650387040699LL,654340820912LL,658146134006LL,662085614117LL,666056469868LL,670191528112LL,674129434788LL,678244658489LL,682374196284LL,686688081812LL,690271265374LL,693934884531LL,697669335613LL,701476114214LL,705362572680LL,709141524985LL,713099812776LL,717028460150LL,721142705741LL,724885629014LL,728761045559LL,732693287973LL,736749758856LL,740777465941LL,744795165451LL,748933922613LL,753141880437LL,757242843568LL,761035892912LL,764984543923LL,768950249363LL,773102984392LL,777003979105LL,781115568109LL,785241482297LL,789546215895LL,793534166646LL,797612465314LL,801743227016LL,806016345271LL,810211805523LL,814480115159LL,818815284428LL,823291446273LL,827085965355LL,830720144562LL,834456466195LL,838244378898LL,842172566028LL,845924301174LL,849827622285LL,853747688115LL,857835952990LL,861660536584LL,865519592631LL,869447143796LL,873463619440LL,877522802056LL,881526923721LL,885658701662LL,889838183515LL,894045653761LL,897822674136LL,901760199490LL,905672137349LL,909772129113LL,913735370955LL,917808707266LL,921941106957LL,926210825869LL,930270736103LL,934327743194LL,938472256179LL,942709938267LL,946936098980LL,951165540823LL,955503787958LL,959946162597LL,964024768722LL,967834326462LL,971779514575LL,975763287747LL,979866439324LL,983836311124LL,987983393408LL,992137825256LL,996463258952LL};
int main() {
  int64_t N;
  cin >> N;
  int64_t i = lower_bound(answer.begin(), answer.end(), N) - answer.begin();
  if(i == 0) {
    int64_t t = 1;
    int64_t cnt = 1;
    while(t < N) {
      t = t + __builtin_popcountll(t);
      cnt++;
    } 
    if(t == N) cout << cnt << endl;
    else cout << -1 << endl;
  } else {
    int64_t t = answer[i - 1];
    int64_t cnt = i * 200000000;
    while(t < N) {
      t = t + __builtin_popcountll(t);
      cnt++;
    } 
    if(t == N) cout << cnt << endl;
    else cout << -1 << endl;
 
  }
}
0