結果

問題 No.423 ハムスター語初級(数詞)
ユーザー togaerrortogaerror
提出日時 2016-09-30 11:39:02
言語 Perl
(5.38.2)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 499 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 7,088 KB
実行使用メモリ 5,152 KB
最終ジャッジ日時 2023-08-13 15:21:33
合計ジャッジ時間 910 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,968 KB
testcase_01 AC 5 ms
5,152 KB
testcase_02 AC 5 ms
4,960 KB
testcase_03 AC 5 ms
4,956 KB
testcase_04 AC 5 ms
5,116 KB
testcase_05 AC 5 ms
5,056 KB
testcase_06 AC 5 ms
4,996 KB
testcase_07 AC 5 ms
4,828 KB
testcase_08 AC 4 ms
5,112 KB
testcase_09 AC 5 ms
4,920 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

use strict;
use warnings;

my $s = <>;
chomp $s;
my @str = split //, $s;
my @ans;
for(my $i = 0; $i <= $#str; $i++) {
	if($str[$i] eq 'm') {
		if($i == $#str) {
			push(@ans, 0);
		} elsif($str[$i + 1] eq 'u') {
			push(@ans, 1);
		} else {
			push(@ans, 0);
		}
	}
}

my $num = join '', @ans;
$num = oct "0b" . $num;
$num *= 2;
$num = sprintf "%b", $num;
@ans = split //, $num;

for(my $i = 0; $i <= $#ans; $i++) {
	if($ans[$i] == 0) {
		print "ham";
	} else {
		print "hamu";
	}
}
print $/;

exit;
0