結果
問題 | No.3 ビットすごろく |
ユーザー |
|
提出日時 | 2023-04-10 20:11:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 622 bytes |
コンパイル時間 | 566 ms |
コンパイル使用メモリ | 63,884 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-06 06:40:15 |
合計ジャッジ時間 | 1,920 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 WA * 15 |
ソースコード
#include<iostream>using namespace std;typedef long long ll;const int N = 1e4 + 10;int b[N];int main(){cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);int n;cin >> n;int w = 1, i = 1;while(i < n){if(b[i]){cout << -1;return 0;}int u = i, ans = 0;while(u){if(u & 1) ans ++ ;u >>= 1;}b[i] = 1;if(i + ans <= n) i += ans;else i -= ans;w ++ ;}// 1 2 3 5 7 10 12if(i != n) cout << -1;else cout << w;return 0;}