結果
問題 |
No.3 ビットすごろく
|
ユーザー |
![]() |
提出日時 | 2015-10-09 12:28:13 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 744 bytes |
コンパイル時間 | 466 ms |
コンパイル使用メモリ | 63,344 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 02:22:04 |
合計ジャッジ時間 | 1,466 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 WA * 15 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int BitCount(int number,int serch_bitnum){ int counter = 0; for(int i = 0; i < serch_bitnum; i++)if(number & (1 << i))counter++; return counter; } bool Found(vector<int> meta,int data){ for(int i = 0; i < meta.size()-1; i++){if(meta[i] == data)return true;} return false; } int main(){ int N; vector<int> onCell; int cellcount = 0; int cell = 1; int step = -1; cin >> N; while(1){ onCell.push_back(cell); cellcount++; if(cell == N){ cout << cellcount << endl; break; }else if(Found(onCell,cell)){ cout << -1 << endl; break; }else{ step = BitCount(cell,16); cell += cell+step <= N ? step : -step; } } return 0; }