记录编号 112487 评测结果 AAAAAAAAAAAAAAAAAAAA
题目名称 [東方S1] 西行寺幽幽子 最终得分 100
用户昵称 GravatarFoolMike 是否通过 通过
代码语言 Pascal 运行时间 0.046 s
提交时间 2014-07-16 09:42:45 内存使用 0.28 MiB
显示代码纯文本
var
s1,s2:ansistring;
c,d,e,f,g:longint;
a,b,ans:array[0..20001]of integer;

procedure zj(w:longint);
var
i,j:longint;
begin
j:=0;
for i:=w to w+e do
  begin
  a[i]:=a[i]+10+j-b[i-w+1];
  j:=a[i] div 10-1;
  a[i]:=a[i] mod 10;
  end;
end;

begin
assign(input,'spring.in');
assign(output,'spring.out');
reset(input);
rewrite(output);

readln(s1);
d:=length(s1);
for c:=1 to d do
a[c]:=ord(s1[d-c+1])-48;
readln(s2);
e:=length(s2);
for c:=1 to e do
b[c]:=ord(s2[e-c+1])-48;

for c:=d-e+1 downto 1 do
  begin
  g:=1;
  for f:=c+e downto c do
  if a[f]>b[f-c+1] then
    begin
    g:=0;break;
    end
    else
    if a[f]<b[f-c+1] then break;
  if a[f]=b[f-c+1] then g:=0;
  while g=0 do
    begin
    zj(c);
    inc(ans[c]);
    g:=1;
    for f:=c+e downto c do
    if a[f]>b[f-c+1] then
      begin
      g:=0;break;
      end
      else
      if a[f]<b[f-c+1] then break;
    if a[f]=b[f-c+1] then g:=0;
    end;
  end;

g:=20001;
while (ans[g]=0)and(g<>0) do dec(g);
if g=0 then
  begin
  writeln('0');
  exit;
  end;
for c:=g downto 1 do
write(ans[c]);
writeln;
close(input);close(output);
end.