結果
| 問題 |
No.3 ビットすごろく
|
| コンテスト | |
| ユーザー |
rinyuushoku
|
| 提出日時 | 2020-08-17 13:34:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,771 bytes |
| コンパイル時間 | 1,752 ms |
| コンパイル使用メモリ | 167,400 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-11 10:59:19 |
| 合計ジャッジ時間 | 14,107 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 WA * 16 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
int main()
{
ll N;
cin >> N;
vll dp(N+1, inf);
dp[0] = 0;
dp[1] = 1;
// rep(j, 0, 10000) {
// rep(i, 0, N+1) {
// ll mv = __builtin_popcount(i);
// if (i+mv <= N) {
// chmin(dp[i+mv], dp[i] + 1);
// }
// if (i-mv >= 1) {
// chmin(dp[i-mv], dp[i] + 1);
// }
// }
// rep(i, 0, N+1) {
// ll mv = __builtin_popcount(i);
// if (i+mv <= N) {
// chmin(dp[i+mv], dp[i] + 1);
// }
// }
// }
// print1d(dp);
ll pos = 1;
ll ans = 1;
rep(i, 0, 100000000) {
++ans;
ll mv = __builtin_popcount(pos);
if (pos+mv <= N) pos += mv;
else if (pos-mv >= 1) pos -= mv;
if (pos == N) {
cout << ans << endl;
return 0;
}
}
cout << -1 << endl;
}
rinyuushoku