跪求大神指点

P2010 [NOIP2016 普及组] 回文日期

charles547 @ 2016-12-14 18:14:10

var
  n,m,g,s,b,q,l,k,i,hw,ny,nr,ans:longint;
  t:boolean;
begin
  assign(input,'date.in');reset(input);
  assign(output,'date.out');rewrite(output);
  readln(n);
  readln(m);
  if n=m then
  begin
    g:=n mod 10;
    s:=n mod 100 div 10;
    b:=n mod 1000 div 100;
    q:=n mod 10000 div 1000;
    if (n div 10000)=(g*1000+s*100+b*10+q) then writeln(1) else writeln(0);
    close(input);close(output);
    halt;
  end;
  l:=n div 10000;
  k:=m div 10000;
  for i:=l to k do
  begin
    t:=false;
    g:=i mod 10;
    s:=i mod 100 div 10;
    b:=i mod 1000 div 100;
    q:=i mod 10000 div 1000;
    hw:=g*1000+s*100+b*10+q; ny:=hw div 100; nr:=hw mod 100;
    case ny of
      1,3,5,7,8,10,12:if nr in [1..31] then t:=true;
      4,6,9,11:if nr in [1..30] then t:=true;
      2:begin
          if ((i mod 4=0)and(i mod 100<>0))or(i mod 400=0) then if ny in [1..29] then t:=true;
          if not (((i mod 4=0)and(i mod 100<>0))or(i mod 400=0)) then if ny in [1..28] then t:=true;
        end;
    end;
    if t then
      if not ((i<(n div 10000))or(hw>(m div 10000))) then inc(ans);
  end;
  writeln(ans);
  close(input);close(output);
end.

by cs_zhao @ 2016-12-16 18:17:54

你提交后是什么结果?


|