結果

問題 No.423 ハムスター語初級(数詞)
ユーザー kohaku_kohaku
提出日時 2016-11-13 21:13:05
言語 Java
(openjdk 23)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 747 bytes
コンパイル時間 2,526 ms
コンパイル使用メモリ 76,544 KB
実行使用メモリ 52,424 KB
最終ジャッジ日時 2024-11-25 21:57:48
合計ジャッジ時間 3,815 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

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