結果

問題 No.423 ハムスター語初級(数詞)
ユーザー kazapyon27kazapyon27
提出日時 2017-06-25 12:22:26
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 962 bytes
コンパイル時間 3,490 ms
コンパイル使用メモリ 77,752 KB
実行使用メモリ 52,336 KB
最終ジャッジ日時 2024-04-15 01:18:58
合計ジャッジ時間 4,282 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
50,676 KB
testcase_01 AC 56 ms
50,648 KB
testcase_02 AC 56 ms
50,468 KB
testcase_03 AC 56 ms
50,472 KB
testcase_04 AC 56 ms
50,312 KB
testcase_05 AC 56 ms
50,732 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

/*No.423 ハムスター語初級(数詞)*/
import java.io.*;
public class No423 {
	public static void main(String[] args) {
		try(BufferedReader input =new BufferedReader(new InputStreamReader(System.in))){
			String Language=input.readLine().replaceAll("hamu", "1").replaceAll("ham", "0");
			int Num=0;
			for(int i=0;i<Language.length();i++){
				Num+=Integer.parseInt(Language.substring(i, i+1))*Math.pow(2,Language.length()-1-i);
			}
			TransNumber(Num*2);
			System.out.println(Integer.toString(TransNumber(Num*2)).replaceAll("1", "hamu").replaceAll("0", "ham"));
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	public static int TransNumber(int TransNumber){
		int n=0;
		String s_number=new String();
		while(TransNumber>=(int)Math.pow(2, n)){
			n++;
		}
		while(n>=0){
			s_number=s_number.concat(Integer.toString(TransNumber/(int)Math.pow(2, n)));
			TransNumber%=(int)Math.pow(2, n);
			n--;
		}
		return Integer.parseInt(s_number);
	}
}
0