60分,不知道哪错了555.有没有神犇帮我看一下?

P2010 [NOIP2016 普及组] 回文日期

翀哥 @ 2016-12-21 09:44:00

请大神们帮我看一下该怎么改?

const
 month:array[1..12]of 28..31=(31,28,31,30,31,30,31,31,30,31,30,31);
 monthren:array[1..12]of 29..31=(31,29,31,30,31,30,31,31,30,31,30,31);
var
 d1,d2,n1,n2,y1,y2,r1,r2,yr,x{回文后的月日},c{回文后的月},e{回文后的日},i,tot:longint;
begin
 tot:=0;
 read(d1,d2);
 n1:=d1 div 10000; n2:=d2 div 10000;
 y1:=d1 mod 10000 div 100; y2:=d2 mod 10000 div 100;
 r1:=d1 mod 100; r2:=d2 mod 100;
 for i:=n1 to n2 do
  begin
   x:=(i mod 10)*1000+(i mod 100 div 10)*100+(i mod 1000 div 100)*10+(i div 1000);
   c:=x div 100;
   e:=x mod 100;
   yr:=i mod 10000;
   if (i<>n1) and (i<>n2) then 
    begin
    if ((i mod 4=0) and (i mod 100<>0)) or (i mod 400=0) then
     if (i=yr) and (c<=12) and (e<=monthren[c]) then inc(tot) else if (i=x) and (c<=12) and (e<=month[c]) then inc(tot);
    end;   
   if i=n1 then
    begin
     if ((i mod 4=0) and (i mod 100<>0)) or (i mod 400=0) then
      begin
       if (i=yr) and (c>=y1) and (c<=12) and (e<=monthren[c]) and (e>=r1) then inc(tot) 
      end
     else if (i=yr) and (c>=y1) and (c<=12) and (e<=month[c]) and (e>=r1) then inc(tot);   
    end;  
   if (i=n2) and (i<>n1) then
    begin
     if ((i mod 4=0) and (i mod 100<>0)) or (i mod 400=0) then 
      begin
       if (i=yr) and (c>=y2) and (c<=12) and (e<=monthren[c]) and (e>=r2) then inc(tot) 
       end
      else if (i=yr) and (c>=y2) and (c<=12) and (e<=month[c]) and (e>=r2) then inc(tot);
    end;  
  end;
 writeln(tot); 
end.

|