結果
問題 | No.423 ハムスター語初級(数詞) |
ユーザー |
|
提出日時 | 2016-09-22 22:48:01 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 32 ms / 2,000 ms |
コード長 | 662 bytes |
コンパイル時間 | 840 ms |
コンパイル使用メモリ | 111,276 KB |
実行使用メモリ | 27,020 KB |
最終ジャッジ日時 | 2024-11-17 14:59:33 |
合計ジャッジ時間 | 1,708 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
コンパイルメッセージ
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;public class Program{public static void Main(){var line = Console.ReadLine();var sb = new StringBuilder();while (!string.IsNullOrEmpty(line)){int i;if (line.StartsWith("hamu")){sb.Append(1);i = 4;}else{sb.Append(0);i = 3;}line = line.Substring(i, line.Length - i);}var chars = sb.ToString().ToCharArray();int num = 0;foreach (var ch in chars){num += ch - '0';num <<= 1;}var bin = Convert.ToString(num, 2);Console.WriteLine(bin.Replace("1", "hamu").Replace("0", "ham"));}}