結果

問題 No.423 ハムスター語初級(数詞)
ユーザー shinwisteriashinwisteria
提出日時 2017-03-30 22:34:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 523 bytes
コンパイル時間 3,265 ms
コンパイル使用メモリ 72,564 KB
実行使用メモリ 56,352 KB
最終ジャッジ日時 2023-09-21 08:56:28
合計ジャッジ時間 5,609 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,580 KB
testcase_01 AC 121 ms
56,240 KB
testcase_02 AC 123 ms
56,160 KB
testcase_03 AC 122 ms
55,676 KB
testcase_04 AC 123 ms
56,352 KB
testcase_05 AC 122 ms
55,780 KB
testcase_06 AC 123 ms
55,756 KB
testcase_07 AC 123 ms
55,772 KB
testcase_08 AC 119 ms
56,108 KB
testcase_09 AC 121 ms
55,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Hamgo {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String n = s.nextLine();
		s.close();
		n = n.replaceAll("hamu", "1");
		n = n.replaceAll("ham", "0");
		
		int k = 2 * Integer.parseUnsignedInt(n, 2);
		n = Integer.toBinaryString(k);
		StringBuilder ans = new StringBuilder();
		for(int i = 0;i < n.length();i++){
			if(n.charAt(i) == '1'){
				ans.append("hamu");
			}else{
				ans.append("ham");
			}
		}
		System.out.println(ans);

	}

}
0