結果
問題 |
No.3 ビットすごろく
|
ユーザー |
![]() |
提出日時 | 2015-03-12 22:16:59 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,124 bytes |
コンパイル時間 | 657 ms |
コンパイル使用メモリ | 68,904 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-24 19:21:27 |
合計ジャッジ時間 | 1,831 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 32 WA * 1 |
ソースコード
#include <cstdio> #include <cmath> #include <iostream> #include <vector> #include <list> #include <algorithm> int main() { /* default begin */ long i, j, k; long n, m; long temp; long t; std::vector<long> v; bool b; /* default end */ long N; long count; long d1[11000] = {}; long d2[11000] = {}; std::cin >> N; for(i = 1; i <= N; i++) { count = 0; temp = i; while( temp != 0 ) { count += (temp & 0x01); temp >>= 1; } d1[i] = count; d2[i] = -1; } d2[1] = 0; for(i = 0; i < N; i++) { b = true; for(j = 1; j <= N; j++) { if( d2[j] == i ) { b = false; temp = j + d1[j]; if( 1 <= temp && temp <= N ) { if( d2[temp] == -1 ) { d2[temp] = i+1; if( temp == N ) { goto label_1; } } } temp = j - d1[j]; if( 1 <= temp && temp <= N ) { if( d2[temp] == -1 ) { d2[temp] = i+1; if( temp == N ) { goto label_1; } } } } } if( b ) { break; } } std::cout << "-1" << std::endl; return 0; label_1: std::cout << d2[temp] + 1 << std::endl; return 0; }