結果
| 問題 |
No.3 ビットすごろく
|
| コンテスト | |
| ユーザー |
_matumo_
|
| 提出日時 | 2018-06-02 23:13:15 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,210 bytes |
| コンパイル時間 | 2,282 ms |
| コンパイル使用メモリ | 115,188 KB |
| 実行使用メモリ | 27,352 KB |
| 最終ジャッジ日時 | 2024-06-30 09:09:40 |
| 合計ジャッジ時間 | 2,986 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 31 WA * 2 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace YukiCoder
{
class Program
{
static int[] bitCnt = new int[] { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
static int[] pnStep;
static int nMax;
static int pnBitN(int ni)
{
return bitCnt[ni % 16]
+ bitCnt[ni / 16 % 16]
+ bitCnt[ni / 16 / 16 % 16]
+ bitCnt[ni / 16 / 16 / 16 % 16];
}
static int zzz(int ns, int ni)
{
if (ni < 1 || ni > nMax) return nMax;
if (ni == nMax) return 1;
if (ns >= pnStep[ni]) return nMax;
pnStep[ni] = ns;
int n = pnBitN(ni);
int na = zzz(ns + 1, ni + n);
int nb = zzz(ns + 1, ni - n);
return (na < nb ? na : nb) + 1;
}
static void Main(string[] args)
{
nMax = int.Parse(Console.ReadLine());
pnStep = (new Int32[nMax]).Select(s => nMax).ToArray();
int n = zzz(1, 1);
if (n >= nMax) n = -1;
Console.WriteLine(n);
Console.ReadLine();
}
}
}
_matumo_