結果

問題 No.423 ハムスター語初級(数詞)
ユーザー jousenjousen
提出日時 2016-09-22 22:58:16
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,756 bytes
コンパイル時間 894 ms
コンパイル使用メモリ 116,564 KB
実行使用メモリ 27,568 KB
最終ジャッジ日時 2024-04-28 19:54:07
合計ジャッジ時間 1,799 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
25,544 KB
testcase_01 WA -
testcase_02 AC 32 ms
27,568 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 31 ms
27,428 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Collections;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace tes
{
	class contest
	{
		static void Main(string[] args)
		{
			
             var s = Console.ReadLine();

            var dic = new Dictionary<string, int>();
            dic["ham"] = 0;
            dic["hamu"] = 1;


            int num = 0;
            var list = new List<int>();

            for(int i =s.Length-1; i>=0; )
            {
                string tmp = "";
                if(s[i] == 'u')
                {
                    tmp = s.Substring(i-3, 4);
                    list.Add(dic[tmp]);
                    i -= 4;
                }
                else
                {
                    tmp = s.Substring(i - 2, 3);
                    list.Add(dic[tmp]);
                    i -= 3;
                }
            }

            list.Reverse();

            num = int.Parse(list.Select(x=>x.ToString()).Aggregate((a,b)=>a+b));

            int memo = 0;
            for (int i = 0; i < num.ToString().Length; i++)
            {
                int t = (int)Math.Pow(2, i);
                memo += int.Parse(num.ToString().Substring(i,1))*t;
            }

            memo <<= 1;

            var ans = new List<string>();

            string d = Convert.ToString(memo,2);

            for (int i = 0; i <d.Length; i++)
            {
                if (((memo >> i) & 1) == 1)
                {
                    ans.Add("hamu");
                }
                else
                {
                    ans.Add("ham");
                }
            }


            ans.Reverse();

            
            ans.ForEach(Console.Write);
			
            
		}		
		 
	}
}
0