讨论 / 这题给的时限是多少?
zhenghan3 2011-08-08 01:30:00
点我顶贴 收藏 删除
一交上所有数据都超时

可是我把数据弄出来之后在自己电脑上测很快,绝对不超过1s,怎么回事

program aa;

const dayr:array[1..12] of longint=(31,29,31,30,31,30,31,31,30,31,30,31);

dayp:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);

var n,y,r,xq,xqans,rans,i:longint;

day:array[1..12] of longint;

procedure init;

var ch:char;

s:string;

begin

assign(input,'test.in');reset(input);

s:='';ch:=' ';

while ch<>'-' do begin read(ch);if ch<>'-' then s:=s+ch;end;

val(s,n);ch:=' ';s:='';

while ch<>'-' do begin read(ch);if ch<>'-' then s:=s+ch;end;

val(s,y);ch:=' ';s:='';

while ord(ch)<>13 do begin read(ch);if ord(ch)<>13 then s:=s+ch;end;

val(s,r);

readln(xq);

readln(xqans);

ch:=' ';s:='';

while ord(ch)<>26 do begin read(ch);if ord(ch)<>26 then s:=s+ch;end;

val(s,rans);

end;

function cac(t:longint):boolean;

begin

if (t mod 4=0) and (t mod 100<>0) then exit(true);

if t mod 400=0 then exit(true);

exit(false);

end;

begin

init;

if cac(n) then day:=dayr else day:=dayp;

repeat

dec(r);

if (r=0) and (y=1) then begin dec(n);if cac(n) then day:=dayr else day:=dayp;y:=12;r:=day[y];end else

if r=0 then begin dec(y);r:=day[y];end;

if xq=1 then xq:=7 else dec(xq);

until (xq=xqans) and (r=rans);

if n<1000 then write(0);

if n<100 then write(0);

if n<10 then write(0);write(n,'-');

if y<10 then write(0);write(y,'-');

if r<10 then write(0);write(r);

end.

查看更多回复
提交回复