记录编号 | 22144 | 评测结果 | AAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | 拯救 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | Pascal | 运行时间 | 0.135 s | ||
提交时间 | 2010-11-17 14:42:57 | 内存使用 | 0.12 MiB | ||
program savey(input,output); var n,i,j:longint; a:array[1..1000]of integer; f:array[0..1000]of ansistring; p,ans:ansistring; x,y:longint; procedure gj(s:ansistring); var a:array[0..500]of integer; k:longint; i:longint; ch:char; begin a[0]:=length(s); for i:=1 to a[0]+1 do a[i]:=0; for i:=1 to length(s) do a[i]:=ord(s[a[0]-i+1])-ord('0'); k:=1; for i:=1 to a[0] do begin a[i]:=2*a[i]+k; k:=a[i] div 10; a[i]:=a[i] mod 10; end; if k<>0 then begin inc(a[0]); a[a[0]]:=k; end; for i:=1 to a[0] do begin ch:=chr(a[a[0]-i+1]+ord('0')); p:=p+ch; end; end; procedure op(s1,s2:ansistring); var i,k:longint; x:longint; ch:char; a,b:array[0..500]of longint; begin a[0]:=length(s1); b[0]:=length(s2); if a[0]>b[0] then x:=a[0] else x:=b[0]; for i:=1 to x+1 do begin a[i]:=0; b[i]:=0; end; for i:=1 to length(s1) do a[i]:=ord(s1[a[0]-i+1])-ord('0'); for i:=1 to length(s2) do b[i]:=ord(s2[b[0]-i+1])-ord('0'); k:=0; for i:=1 to length(s1) do begin a[i]:=a[i]-b[i]-k; if a[i]<0 then begin k:=1; a[i]:=10+a[i]; end else k:=0; end; if a[a[0]]=0 then dec(a[0]); for i:=1 to a[0] do begin ch:=chr(a[a[0]-i+1]+ord('0')); p:=p+ch; end; end; begin assign(input,'savey.in'); reset(input); readln(n); for i:=1 to n do read(a[i]); close(input); f[1]:='1'; for i:=2 to n do begin p:=''; gj(f[i-1]); f[i]:=p; end; writeln(f[1000]); ans:='0'; for i:=1 to n do if a[i]=1 then begin p:=''; op(f[i],ans); ans:=p; end; assign(output,'savey.out'); rewrite(output); writeln(ans); close(output); end.