結果
問題 |
No.3 ビットすごろく
|
ユーザー |
|
提出日時 | 2019-07-10 14:54:03 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 510 bytes |
コンパイル時間 | 1,360 ms |
コンパイル使用メモリ | 157,556 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2024-10-15 13:37:30 |
合計ジャッジ時間 | 7,975 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 2 TLE * 1 -- * 30 |
ソースコード
#include "bits/stdc++.h" using namespace std; int bitCount(int bits) { int cnt = 0; for(int mask = 1; mask != 0; mask<<=1) { if( (bits & mask) != 0 ) ++cnt; } return cnt; } int main() { int N = 0; cin >> N; int count = 0; int pos = 1; while(1) { if(pos ==N) break; int c = bitCount(pos); pos += c; if(pos > N) { pos -=2*c; } ++count; } cout << count << endl; return 0; }