結果

問題 No.423 ハムスター語初級(数詞)
ユーザー kazapyon27kazapyon27
提出日時 2017-06-25 12:22:26
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 962 bytes
コンパイル時間 3,954 ms
コンパイル使用メモリ 74,296 KB
実行使用メモリ 50,316 KB
最終ジャッジ日時 2023-07-27 13:18:12
合計ジャッジ時間 5,034 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
49,956 KB
testcase_01 AC 52 ms
50,224 KB
testcase_02 AC 50 ms
49,940 KB
testcase_03 AC 50 ms
50,312 KB
testcase_04 AC 51 ms
50,316 KB
testcase_05 AC 51 ms
49,916 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