結果

問題 No.423 ハムスター語初級(数詞)
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-13 21:13:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 747 bytes
コンパイル時間 2,328 ms
コンパイル使用メモリ 73,756 KB
実行使用メモリ 56,120 KB
最終ジャッジ日時 2023-08-17 04:22:41
合計ジャッジ時間 4,545 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,960 KB
testcase_01 AC 124 ms
55,664 KB
testcase_02 AC 122 ms
55,912 KB
testcase_03 AC 122 ms
55,712 KB
testcase_04 AC 122 ms
56,072 KB
testcase_05 AC 121 ms
55,944 KB
testcase_06 AC 121 ms
55,768 KB
testcase_07 AC 121 ms
56,036 KB
testcase_08 AC 123 ms
56,120 KB
testcase_09 AC 123 ms
56,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        String a = "";
        while( !(n.equals("")) ){
            if( n.indexOf("hamu")==0  ){
                a=a+"1";
                n=n.substring(4);
            }else{
                a=a+"0";
                n=n.substring(3);
            }
        }
        int b = 2*Integer.parseInt(a, 2);
        String c = Integer.toBinaryString(b);
        for(int i=0; i<c.length(); i++){
            if(c.charAt(i)=='1' ){
                System.out.print("hamu");
            }else{
                System.out.print("ham");
            }
        }
        System.out.println();
    }
}
0