結果

問題 No.423 ハムスター語初級(数詞)
ユーザー qwrtpsfgqwrtpsfg
提出日時 2017-08-15 22:11:14
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 1,150 bytes
コンパイル時間 754 ms
コンパイル使用メモリ 105,472 KB
実行使用メモリ 18,048 KB
最終ジャッジ日時 2024-04-21 12:34:44
合計ジャッジ時間 1,465 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
18,048 KB
testcase_01 AC 20 ms
18,048 KB
testcase_02 AC 20 ms
17,792 KB
testcase_03 AC 20 ms
17,920 KB
testcase_04 AC 20 ms
17,792 KB
testcase_05 AC 22 ms
17,920 KB
testcase_06 AC 21 ms
17,792 KB
testcase_07 AC 21 ms
17,920 KB
testcase_08 AC 22 ms
17,664 KB
testcase_09 AC 22 ms
17,792 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;

public class yukicoder
{
    public static int hamtodecimal(string s)
    {
        string[] ham = s.Split(new String[]{"ha"}, StringSplitOptions.RemoveEmptyEntries);
        
        for(int i = 0; i < ham.Length; i++)
        {
            if(ham[i] == "mu")
            {
                ham[i] = "1";
            }
            else if(ham[i] == "m")
            {
                ham[i] = "0";
            }
        }
        
        return Convert.ToInt32(String.Join(null, ham), 2);
    
    }
    
    public static string decimaltoham(int n)
    {
        string s = Convert.ToString(n, 2);
        List<String> ham = new List<String>();
        
        foreach(char c in s)
        {
            if(c == '1')
            {
                ham.Add("hamu");
            }
            else if(c == '0')
            {
                ham.Add("ham");
            }
        }
        
        return String.Join(null, ham);
    }
    
    public static void Main()
    {
        int n = hamtodecimal(Console.ReadLine()) * 2;
        Console.WriteLine(decimaltoham(n));
    }
}
0