讨论 / WA70实在不知道为什么错了。。还有个超时
liangjs 2012-06-24 17:27:00
点我顶贴 收藏 删除
type rec=record

y,m,d:integer;

end;

var r1,r3:rec;

q1,q2:integer;

m2:longint;

function how(x:rec):integer;

begin

case x.m of

1,3,5,7,8,10,12:exit(31);

2:if (x.y mod 100<>0)and(x.y mod 4=0)or(x.y mod 400=0) then exit(29) else exit(28);

else exit(30);

end;

end;

procedure ini;

var s:string;

p,c:integer;

begin

readln(s);

val(copy(s,1,4),r1.y,c);

val(copy(s,6,2),r1.m,c);

val(copy(s,9,2),r1.d,c);

readln(q1,q2,r3.d);

r3.y:=r1.y;

r3.m:=r1.m;

if r1.d<r3.d then begin

dec(r3.m);

if r3.m=0 then begin r3.m:=12; dec(r3.y); end;

m2:=how(r3)-r3.d+r1.d;

end else m2:=abs(r1.d-r3.d);

end;

procedure pp(x:rec);

var s:string;

begin

str(x.y,s);

while length(s)<4 do s:='0'+s;

write(s,'-');

if x.m div 10=0 then write('0',x.m,'-') else write(x.m,'-');

if x.d div 10=0 then writeln('0',x.d) else writeln(x.d);

end;

begin

ini;

while (((q1-m2 mod 7) mod 7+7) mod 7<>q2)or(how(r3)<r3.d) do begin

dec(r3.m);

if r3.m=0 then begin r3.m:=12; dec(r3.y); end;

inc(m2,how(r3));

end;

pp(r3);

end.

查看更多回复
提交回复