結果
問題 | No.423 ハムスター語初級(数詞) |
ユーザー | nullzine |
提出日時 | 2017-01-18 21:28:10 |
言語 | Java19 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 844 bytes |
コンパイル時間 | 6,279 ms |
コンパイル使用メモリ | 76,624 KB |
実行使用メモリ | 56,996 KB |
最終ジャッジ日時 | 2023-08-24 17:07:24 |
合計ジャッジ時間 | 6,082 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 158 ms
56,788 KB |
testcase_01 | AC | 161 ms
56,800 KB |
testcase_02 | AC | 161 ms
56,896 KB |
testcase_03 | AC | 163 ms
56,728 KB |
testcase_04 | AC | 169 ms
56,852 KB |
testcase_05 | WA | - |
testcase_06 | AC | 162 ms
56,836 KB |
testcase_07 | AC | 162 ms
56,980 KB |
testcase_08 | AC | 161 ms
56,996 KB |
testcase_09 | AC | 164 ms
56,600 KB |
ソースコード
public class Main { public static void main(String[] args){ new Main().run(); } private void run(){ System.out.println(bin2Ham(dec2Bin(bin2Dec(ham2Bin(new java.util.Scanner(System.in).nextLine()))*2))); } private int bin2Dec(String str){ int ret=0; for(int i=0;i<str.length();i++){ ret+=Integer.parseInt(str.charAt(str.length()-1-i)+"")*Math.pow(2, i); } return ret; } private String dec2Bin(int n){ String str=""; while(n!=0){ str=(n%2)+str; n/=2; } return str; } private String bin2Ham(String bin){ return bin.replaceAll("0","ham").replaceAll("1","hamu"); } private String ham2Bin(String ham){ return ham.replaceAll("hamu","1").replaceAll("ham","0"); } }