結果

問題 No.3 ビットすごろく
ユーザー kendemukendemu
提出日時 2015-06-01 17:07:57
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,004 bytes
コンパイル時間 539 ms
コンパイル使用メモリ 77,316 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-20 18:20:12
合計ジャッジ時間 1,735 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <vector>
#include <bitset>
#include <deque>
#include <queue>

int numofbits(long bits){
  bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
  bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
  bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
  bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
  return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

long long int N;
long long int move;


int main(int argc, char** argv){
  std::cin >> N;
  float amount = std::floor(log2(N));
  if(amount <= 0) amount = 0;
  std::queue<long> q;
  for(float i = N; std::ceil(log2(i)) + 1> log2(N); i--){
    if(i + numofbits(i) == N) q.push(i); 
  }
  std::cerr << "bits:" << amount << std::endl;
  if(q.empty()) std::cout << "-1" << std::endl;
  else{
    for(unsigned int i = 0; i< q.size(); i++){
      std::cout << q.front() << std::endl;
      q.pop();
    }
  }
}
0