結果
問題 | No.423 ハムスター語初級(数詞) |
ユーザー | Mcpu3 |
提出日時 | 2018-10-06 19:50:55 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 119 ms / 2,000 ms |
コード長 | 1,194 bytes |
コンパイル時間 | 2,227 ms |
コンパイル使用メモリ | 76,880 KB |
実行使用メモリ | 54,680 KB |
最終ジャッジ日時 | 2024-04-20 18:06:14 |
合計ジャッジ時間 | 3,481 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 107 ms
53,220 KB |
testcase_01 | AC | 119 ms
54,404 KB |
testcase_02 | AC | 100 ms
52,960 KB |
testcase_03 | AC | 103 ms
53,588 KB |
testcase_04 | AC | 99 ms
53,220 KB |
testcase_05 | AC | 96 ms
54,032 KB |
testcase_06 | AC | 116 ms
54,680 KB |
testcase_07 | AC | 98 ms
52,668 KB |
testcase_08 | AC | 110 ms
54,164 KB |
testcase_09 | AC | 117 ms
54,176 KB |
ソースコード
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); char n[] = new char[51]; n = sc.next().toCharArray(); sc.close(); int length = n.length, tmp1[] = new int[16], tmp2 = 0, i, j = 0; for (i = 0; i < length - 3; ++i) { if (n[i] == 'h' && n[i + 1] == 'a' && n[i + 2] == 'm' && n[i + 3] != 'u') { tmp1[j] = 0; i += 2; } else { tmp1[j] = 1; i += 3; } ++j; } if (n[length - 3] == 'h' && n[length - 2] == 'a' && n[length - 1] == 'm') { tmp1[j] = 0; ++j; } for (i = 0; i < j; ++i) { if (tmp1[j - i - 1] == 1) tmp2 += (int)Math.pow(2, i); } tmp2 *= 2; j = 0; for (i = 31; i >= 0; --i) { if ((tmp2 >> i & 1) == 1) { System.out.print("hamu"); j = 1; } else if (j == 1) System.out.print("ham"); } if (j == 0) System.out.print("ham"); } }