結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
nak2yoshi
|
| 提出日時 | 2016-02-25 22:51:08 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 679 bytes |
| 記録 | |
| コンパイル時間 | 795 ms |
| コンパイル使用メモリ | 108,160 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-12 03:07:14 |
| 合計ジャッジ時間 | 1,833 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 WA * 15 |
ソースコード
import std.stdio,
std.conv,
std.string,
std.range,
std.math,
std.bigint,
std.algorithm,
core.bitop;
void main()
{
auto N = readln.strip.to!int;
//auto dice = 1.iota(N + 1).map!(a => iota(a.to!real.log2.floor.to!int+1).map!(i => (a>>i)&1).sum).array;
auto dice = 1.iota(N + 1).map!(e => popcnt(e)).array;
int dfs(int i, int c)
{
if (dice[i] == 0)
return -1;
if (i == N - 1)
return c;
auto tmp = dice[i];
dice[i] = 0;
if (i + tmp >= N)
return dfs(i - tmp, c + 1);
return dfs(i + tmp, c + 1);
}
dfs(0, 1).writeln;
}
nak2yoshi