結果
問題 | No.423 ハムスター語初級(数詞) |
ユーザー |
|
提出日時 | 2017-01-18 21:28:10 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 844 bytes |
コンパイル時間 | 2,438 ms |
コンパイル使用メモリ | 78,524 KB |
実行使用メモリ | 54,828 KB |
最終ジャッジ日時 | 2024-12-23 01:22:18 |
合計ジャッジ時間 | 4,895 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 WA * 1 |
ソースコード
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"); } }