結果
| 問題 |
No.3 ビットすごろく
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-13 20:59:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 542 bytes |
| コンパイル時間 | 2,156 ms |
| コンパイル使用メモリ | 197,688 KB |
| 最終ジャッジ日時 | 2025-01-25 17:47:38 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 WA * 15 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
typedef long long ll;
using namespace std;
int main() {
int N;
cin >> N;
int ans = 1;
int now = 1;
set<int> st;
while (now != N && st.find(now) == st.end()) {
st.insert(now);
int diff = __builtin_popcount(now);
if (now + diff <= N)
now += diff;
else
now -= diff;
ans++;
}
if (now == N)
cout << ans;
else
cout << -1;
cout << endl;
return 0;
}