結果
| 問題 | No.3 ビットすごろく | 
| コンテスト | |
| ユーザー |  ferin | 
| 提出日時 | 2017-01-26 21:53:10 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 997 bytes | 
| コンパイル時間 | 1,228 ms | 
| コンパイル使用メモリ | 157,964 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-12-23 11:48:06 | 
| 合計ジャッジ時間 | 2,395 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 8 WA * 25 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12
int dp[11234], n;
bool use[11234];
void dfs(int num) {
  if(use[num]) return;
  int c = __builtin_popcount(num);
  //cout << "num:" << num << " c:" << c << endl;
  //FOR(i, 1, n+1) cout << dp[i] << " "; cout << endl;
  use[num] = true;
  if(num-c > 0) {
    //cout << "-" << endl;
    if(!use[num-c]) dp[num-c] = dp[num] + 1;
    dfs(num-c);
  }
  if(num+c <= n) {
    //cout << "+" << endl;
    if(!use[num+c]) dp[num+c] = dp[num] + 1;
    dfs(num+c);
  }
  return;
}
int main(void)
{
  cin >> n;
  memset(dp, -1, 11234);
  dp[1] = 1;
  dfs(1);
  cout << dp[n] << endl;
  return 0;
}
            
            
            
        