結果
問題 |
No.3 ビットすごろく
|
ユーザー |
|
提出日時 | 2017-08-09 18:37:39 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,142 bytes |
コンパイル時間 | 1,094 ms |
コンパイル使用メモリ | 111,896 KB |
実行使用メモリ | 26,088 KB |
最終ジャッジ日時 | 2024-10-12 04:00:17 |
合計ジャッジ時間 | 2,500 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 WA * 15 |
コンパイルメッセージ
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; public class yukicoder{ public static int move(int n) { string s = Convert.ToString(n, 2); int m = 0; foreach(char c in s) { if(char.IsNumber(c)) { m += int.Parse(c.ToString()); } } return m; } public static void Main(){ int goal = int.Parse(Console.ReadLine()); int[] board = new int[goal]; List<int> usedcell = new List<int>(); for(int i = 0; i < board.Length; i++) { board[i] = i + 1; } int now = 1; while(true) { usedcell.Add(now); if(now == goal) { Console.WriteLine(usedcell.Count); break; } if((now + move(board[now - 1])) > goal) { now -= move(board[now - 1]); if(usedcell.Contains(now)) { Console.WriteLine(-1); break; } } else { now += move(board[now - 1]); } } } }