結果
問題 |
No.3 ビットすごろく
|
ユーザー |
![]() |
提出日時 | 2020-06-30 00:43:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 506 bytes |
コンパイル時間 | 525 ms |
コンパイル使用メモリ | 68,736 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-19 06:10:23 |
合計ジャッジ時間 | 1,353 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 WA * 16 |
ソースコード
#include <iostream> #include <vector> using namespace std; int count_one(int n){ int count = 0; while(n > 0){ if(n % 2 == 1) count++; n /= 2; } return count; } int main(){ int N; cin >> N; int np = 1;//now_position int count = 1; vector<int> pathed(N,0); while(true){ int step = count_one(np); np += step; count++; if(np == N) break; if(np > N) np -= step+step; if(pathed.at(np) == 2){ count = -1; break; } pathed.at(np) += 1; } cout << count << endl; }