結果
| 問題 | No.3 ビットすごろく | 
| コンテスト | |
| ユーザー |  siguma323 | 
| 提出日時 | 2016-04-29 21:46:51 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 749 bytes | 
| コンパイル時間 | 667 ms | 
| コンパイル使用メモリ | 76,424 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-04 17:56:09 | 
| 合計ジャッジ時間 | 1,641 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 12 WA * 21 | 
ソースコード
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
#include <iostream>
#include <queue>
#include <utility>
#include <cmath>
#include <bitset>
using namespace std;
bool used[10001];
int now_bit(int num)
{
    if(used[num]) return -1;
    bitset<8> bs(num);
    used[num] = true;
    return bs.count();
}
int main()
{
    int n;
    cin >> n;
    int pos = 1;
    int count = 1;
    while(pos != n)
    {
        int num = now_bit(pos);
        if(num == -1)
        {
            cout << -1 <<  endl;
            return 0;
        }
        else if(pos + num > n)
        {
            pos -= num;
        }
        else
        {
            pos += num;
        }
        ++count;
    }
    cout << count << endl;
}
            
            
            
        