結果

問題 No.18 うーさー暗号
ユーザー d_nishiyama85d_nishiyama85
提出日時 2015-04-26 22:37:24
言語 PHP
(8.3.4)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 507 bytes
コンパイル時間 1,441 ms
コンパイル使用メモリ 18,580 KB
実行使用メモリ 18,916 KB
最終ジャッジ日時 2023-09-21 11:43:18
合計ジャッジ時間 2,522 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
18,704 KB
testcase_01 AC 16 ms
18,764 KB
testcase_02 AC 16 ms
18,796 KB
testcase_03 AC 17 ms
18,888 KB
testcase_04 AC 17 ms
18,916 KB
testcase_05 AC 17 ms
18,892 KB
testcase_06 AC 17 ms
18,844 KB
testcase_07 AC 17 ms
18,840 KB
testcase_08 AC 17 ms
18,792 KB
testcase_09 AC 16 ms
18,820 KB
testcase_10 AC 16 ms
18,856 KB
testcase_11 AC 16 ms
18,788 KB
testcase_12 AC 16 ms
18,812 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php

$table = [
	'A', 'B', 'C', 'D',
	'E', 'F', 'G', 'H',
	'I', 'J', 'K', 'L',
	'M', 'N', 'O', 'P',
	'Q', 'R', 'S', 'T',
	'U', 'V', 'W', 'X',
	'Y', 'Z'
	];

main();

function main() {
	$S = trim(fgets(STDIN));
	$decrypt = "";
	for($i = 0, $len = strlen($S); $i < $len; $i++) {
		$decrypt .= decryptChar($S[$i], $i + 1);
	}
	echo $decrypt . "\n";
}

function decryptChar($c, $N) {
	global $table;
	$inverse = array_flip($table);
	$i = $inverse[$c];
	$key = ($i + 26 - $N % 26) % 26;
	return $table[$key];
}
0