結果

問題 No.423 ハムスター語初級(数詞)
ユーザー kazapyon27kazapyon27
提出日時 2017-06-25 12:28:56
言語 Java21
(openjdk 21)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 958 bytes
コンパイル時間 3,079 ms
コンパイル使用メモリ 76,984 KB
実行使用メモリ 37,508 KB
最終ジャッジ日時 2024-04-15 01:19:16
合計ジャッジ時間 4,412 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
37,504 KB
testcase_01 AC 55 ms
37,360 KB
testcase_02 AC 55 ms
37,508 KB
testcase_03 AC 59 ms
37,440 KB
testcase_04 AC 59 ms
37,020 KB
testcase_05 AC 61 ms
37,396 KB
testcase_06 AC 60 ms
37,292 KB
testcase_07 AC 61 ms
37,176 KB
testcase_08 AC 60 ms
37,020 KB
testcase_09 AC 59 ms
37,292 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