比赛 NOIP2015普及组练习 评测结果 AAAAAAAAAA
题目名称 Vigenère密码 最终得分 100
用户昵称 lyl610 运行时间 0.009 s
代码语言 Pascal 内存使用 0.15 MiB
提交时间 2015-11-04 13:59:36
显示代码纯文本
var
a:array[1..26,1..26] of char;
s,ss:ansistring;
i,j,l,r,tem,t:longint;
ch:char;
begin
assign(input,'vigenere.in');reset(input);
assign(output,'vigenere.out');rewrite(output);
readln(s);
readln(ss);
for i:=1 to 26 do
for j:=1 to 26 do
begin
tem:=i+j+63;
if tem>90 then tem:=tem-26;
a[i,j]:=chr(tem);
end;
while length(s)<length(ss) do
s:=s+s;
for i:=1 to length(ss) do
begin
t:=0;
if (s[i]>='A')  and (s[i]<='Z')  then l:=ord(s[i])-64;
if (s[i]>='a')  and (s[i]<='z')  then l:=ord(s[i])-96;
if (ss[i]>='A') and (ss[i]<='Z') then
for j:=1 to 26 do
if a[l,j]=ss[i] then
ch:=chr(j+64);
if (ss[i]>='a') and (ss[i]<='z') then
for j:=1 to 26 do
if ord(a[l,j])=ord(ss[i])-32 then
ch:=chr(j+96);
write(ch);
end;
close(input);close(output);
end.