結果

問題 No.18 うーさー暗号
ユーザー togaerrortogaerror
提出日時 2015-04-30 18:28:11
言語 Perl
(5.38.2)
結果
AC  
実行時間 7 ms / 5,000 ms
コード長 381 bytes
コンパイル時間 655 ms
コンパイル使用メモリ 5,324 KB
実行使用メモリ 5,080 KB
最終ジャッジ日時 2023-09-21 11:43:28
合計ジャッジ時間 1,608 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,040 KB
testcase_01 AC 5 ms
4,932 KB
testcase_02 AC 5 ms
4,844 KB
testcase_03 AC 7 ms
5,020 KB
testcase_04 AC 6 ms
4,916 KB
testcase_05 AC 6 ms
4,772 KB
testcase_06 AC 6 ms
5,000 KB
testcase_07 AC 7 ms
4,860 KB
testcase_08 AC 7 ms
4,940 KB
testcase_09 AC 7 ms
5,052 KB
testcase_10 AC 5 ms
5,044 KB
testcase_11 AC 5 ms
5,040 KB
testcase_12 AC 6 ms
5,080 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/perl

use strict;
use warnings;

my @array = ('A'..'Z');
my $s = <>;
chomp $s;
my @str = split //, $s;
my $change;

for(my $i = 0; $i <length $s; $i++) {
	my $j;
	for($j = 0; $j < 26; $j++) {
		if($str[$i] eq $array[$j]) {
			last;
		}
	}
	$change = $j - ($i % 26) - 1;
	if($change < 0) {
		$change += 26;
	}
	$str[$i] = $array[$change];
}

print @str;
print "\n";
exit;
0