結果

問題 No.423 ハムスター語初級(数詞)
ユーザー kazapyon27kazapyon27
提出日時 2017-06-25 12:28:56
言語 Java19
(openjdk 21)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 958 bytes
コンパイル時間 4,052 ms
コンパイル使用メモリ 74,184 KB
実行使用メモリ 50,004 KB
最終ジャッジ日時 2023-07-27 13:19:05
合計ジャッジ時間 5,069 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
49,768 KB
testcase_01 AC 54 ms
49,988 KB
testcase_02 AC 51 ms
49,940 KB
testcase_03 AC 53 ms
49,928 KB
testcase_04 AC 52 ms
47,780 KB
testcase_05 AC 51 ms
49,904 KB
testcase_06 AC 52 ms
49,992 KB
testcase_07 AC 51 ms
49,856 KB
testcase_08 AC 51 ms
49,900 KB
testcase_09 AC 51 ms
50,004 KB
権限があれば一括ダウンロードができます

ソースコード

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(Long.toString(TransNumber(Num*2)).replaceAll("1", "hamu").replaceAll("0", "ham"));
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	public static long 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 Long.parseLong(s_number);
	}
}
0