记录编号 2398 评测结果 AAAAAAAAAA
题目名称 铺砖 最终得分 100
用户昵称 GravatarNickName 是否通过 通过
代码语言 Pascal 运行时间 10.000 s
提交时间 2008-09-20 13:47:07 内存使用 2.02 MiB
显示代码纯文本
program puzhuan;
var x1,x2:longint;
pi,po:text;
n:longint;
jg:longint;
jiyi:array[1..1000000] of integer;
function yunsuan(a:longint):longint;
begin
if a=1 then yunsuan:=1;
if a=2 then yunsuan:=3;
if a>2 then
begin
if jiyi[a-1]=0 then
jiyi[a-1]:=(yunsuan(a-1) mod 12345);
if jiyi[a-2]=0 then
jiyi[a-2]:=(yunsuan(a-2) mod 12345);
yunsuan:=(jiyi[a-1]+2+(jiyi[a-2]-1)*2) mod 12345;
end;
end;
begin
assign(pi,'puzhuan.in');
reset(pi);
readln(pi,n);
for x1:=1 to n do jiyi[x1]:=0;
jg:=yunsuan(n);
assign(po,'puzhuan.out');
rewrite(po);
if jg>12345 then jg:=jg mod 12345;
writeln(po,jg);
close(pi);
close(po);
end.