結果

問題 No.423 ハムスター語初級(数詞)
ユーザー mbanmban
提出日時 2016-09-25 15:58:27
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 1,002 bytes
コンパイル時間 2,310 ms
コンパイル使用メモリ 106,720 KB
実行使用メモリ 23,028 KB
最終ジャッジ日時 2023-08-11 18:21:51
合計ジャッジ時間 3,489 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
20,800 KB
testcase_01 AC 54 ms
21,044 KB
testcase_02 AC 54 ms
20,908 KB
testcase_03 AC 54 ms
21,128 KB
testcase_04 AC 54 ms
22,988 KB
testcase_05 AC 54 ms
20,568 KB
testcase_06 AC 54 ms
23,028 KB
testcase_07 AC 53 ms
21,164 KB
testcase_08 AC 53 ms
22,936 KB
testcase_09 AC 56 ms
21,140 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;

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