結果
問題 |
No.423 ハムスター語初級(数詞)
|
ユーザー |
![]() |
提出日時 | 2016-09-25 15:58:27 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 1,002 bytes |
コンパイル時間 | 1,007 ms |
コンパイル使用メモリ | 113,268 KB |
実行使用メモリ | 26,588 KB |
最終ジャッジ日時 | 2024-11-18 12:26:44 |
合計ジャッジ時間 | 1,896 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; class Magatro { static Dictionary<string,int> HamDic = new Dictionary<string, int>(); static string[] IntHum = { "ham", "hamu" }; static void Main() { for(int i = 0; i < 2; i++) { HamDic.Add(IntHum[i], i); } string n = Console.ReadLine(); Console.WriteLine(tohum(2 * Toint(n))); } static int Toint(string hum) { hum = hum.Replace(IntHum[1], "1"); hum = hum.Replace(IntHum[0], "0"); //return int.Parse(hum); int ret = 0; for(int i = 0; i < hum.Length; i++) { if (hum[hum.Length - 1 - i] == '1') { ret += (int)Math.Pow(2, i); } } return ret; } static string tohum(int n) { //Console.WriteLine(n); string s = Convert.ToString(n, 2); s=s.Replace("1", "hamu"); s= s.Replace("0", "ham"); // Console.WriteLine(s); return s; } }