結果

問題 No.423 ハムスター語初級(数詞)
ユーザー abL8ZLsTbFabL8ZLsTbF
提出日時 2016-09-22 22:48:01
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 662 bytes
コンパイル時間 2,041 ms
コンパイル使用メモリ 106,992 KB
実行使用メモリ 23,484 KB
最終ジャッジ日時 2023-08-11 02:43:02
合計ジャッジ時間 3,573 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
21,480 KB
testcase_01 AC 76 ms
21,464 KB
testcase_02 AC 77 ms
21,624 KB
testcase_03 AC 77 ms
21,384 KB
testcase_04 AC 76 ms
23,484 KB
testcase_05 AC 76 ms
21,440 KB
testcase_06 AC 77 ms
23,444 KB
testcase_07 AC 77 ms
21,456 KB
testcase_08 AC 77 ms
21,448 KB
testcase_09 AC 75 ms
21,468 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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"));
	}
}
0