60分,求解,是用深搜的原因吗

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 条评论

  • @ 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吗

    • @ 2016-11-12 00:24:12

      编译成功

      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(13,9) Note: Local variable "j" not used
      foo.pas(7,7) Note: Local variable "j" not used
      Linking foo.exe
      71 lines compiled, 0.0 sec, 28640 bytes code, 1268 bytes data
      2 note(s) issued
      测试数据 #0: Accepted, time = 0 ms, mem = 808 KiB, score = 10
      测试数据 #1: Accepted, time = 0 ms, mem = 808 KiB, score = 10
      测试数据 #2: Accepted, time = 0 ms, mem = 804 KiB, score = 10
      测试数据 #3: WrongAnswer, time = 0 ms, mem = 812 KiB, score = 0
      测试数据 #4: WrongAnswer, time = 0 ms, mem = 808 KiB, score = 0
      WrongAnswer, time = 0 ms, mem = 812 KiB, score = 30

    • @ 2016-11-12 00:27:29

      深搜只是用来判断某数与某数是否可以互相转换,应该不会TLE吧(只是猜的233)

  • 1

信息

ID
1129
难度
6
分类
高精度 点击显示
标签
递交数
3872
已通过
1107
通过率
29%
被复制
26
上传者