結果
| 問題 | No.3 ビットすごろく | 
| コンテスト | |
| ユーザー |  IL_msta | 
| 提出日時 | 2015-06-03 13:13:57 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,348 bytes | 
| コンパイル時間 | 489 ms | 
| コンパイル使用メモリ | 69,764 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-06 13:53:05 | 
| 合計ジャッジ時間 | 1,276 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 32 WA * 1 | 
ソースコード
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <math.h>
#include <string>
#include <list>
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////
int pop(int n){
	int ans = n;
	ans = ((ans & 0xaaaa)>>1) +(ans&0x5555);
	ans = ((ans & 0xcccc)>>2) +(ans&0x3333);
	ans = ((ans & 0xf0f0)>>4) +(ans&0x0f0f);
	ans = ((ans & 0xff00)>>8) +(ans&0x00ff);
	return ans;
}
int N;
int m[10001];
int d[10001];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed;//
    //cout << setprecision(6);//
	cin>>N;
	
	rep(i,N+1){
		m[i] = pop(i);
		d[i] = -1;
	}
	
	int ans = -1;
	int c[10001];
	int num  = 0;
	int left;
	int temp;
	c[num] = 1;
	d[c[num]] = 1;
	left = 1;
	for(;num<left;)
	{
		temp = c[num] + m[c[num]];
		if( 1 <= temp && temp <= N){
			if(temp == N){
				ans = d[c[num]]+1;
				break;
			}
			if(d[temp] == -1)
			{
				c[left] = temp;
				++left;
				d[temp] = d[c[num]] + 1;
			}
		}
		temp = c[num] - m[c[num]];
		if( 1 <= temp && temp <= N){
			if(temp == N){
				ans = d[c[num]]+1;
				break;
			}
			if(d[temp] == -1)
			{
				c[left] = temp;
				++left;
				d[temp] = d[c[num]] + 1;
			}
		}
		++num;
	}
	P(ans);
    return 0;
}
            
            
            
        