- 产生数
- 2016-10-03 12:31:29 @
type ll = record
s:array[1 .. 50] of longint;
l:longint;
end;
var sum:ll;
shu:array[1 .. 30] of longint;
i,j,k,l:longint;
ss:string;
map:array[0 .. 9,0 .. 9] of boolean;
bmap:array[0 .. 9] of boolean;
smap:array[0 .. 9] of longint;
function c(a:ll;b:longint):ll;
var x,i,j:longint;
begin
x := 0; c.l := a.l;
for i := 1 to a.l do
begin
c.s[i] := (a.s[i] * b + x) mod 10;
x := (a.s[i] * b + x) div 10;
end;
if x > 0 then
begin
inc(c.l);
c.s[c.l] := x;
end;
end;
function s(a:longint):longint;
var i:longint;
begin
s := 0;
if bmap[a] then
begin
s := 1;
bmap[a] := false;
for i := 1 to 9 do
if map[a,i] then inc(s,s(i));
end;
end;
procedure init;
var i,a,b:longint;
begin
fillchar(map,sizeof(map),false);
readln(ss);
i := 1;
while ss[i] <> ' ' do
begin
shu[i] := ord(ss[i]) - 48;
inc(i);
end;
l := i - 1;
val(copy(ss,i+1,length(ss)-i),k);
for i := 1 to k do
begin
read(a,b);
map[a,b] := true;
end;
end;
begin
init;
for i := 1 to 9 do
begin
fillchar(bmap,sizeof(bmap),true);
smap[i] := s(i);
end;
sum.l := 1;
sum.s[1] := 1;
for i := 1 to l do sum := c(sum,smap[shu[i]]);
for i := sum.l downto 1 do write(sum.s[i]);
end.
3 条评论
-
易极feng LV 9 @ 2016-11-14 20:00:26
%%%%%%%%%%%%%%%%%%%HYH大学霸
-
2016-11-10 19:27:49@
我测了一下
Free Pascal Compiler version 3.0.0 [2015/11/16] for i386
Copyright (c) 1993-2015 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling foo.pas
foo.pas(18,19) Fatal: Syntax error, ")" expected but "identifier B" found
Fatal: Compilation aborted
Error: C:\FPC\3.0.0\bin\i386-win32\ppc386.exe returned an error exitcode
CompileError, time = 0 ms, mem = 0 KiB, score = 0 -
2016-11-10 19:26:33@
是TLE吗
- 1