Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
再来,146097,2400年的元旦In Reply To:这个问题解决了,但还是WA…… Posted by:JiangLY at 2005-06-04 12:48:26 > const > c:array[1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31); > p:array[1..7] of string=('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'); > var > y,m,d,w,i,n:longint; > function ok(q:longint):boolean; > begin > if (q mod 100=0)and(q mod 400=0) then ok:=true > else if (q mod 100<>0)and(q mod 4=0) then ok:=true > else ok:=false; > end; > begin > while true do > begin > readln(n); > if n=-1 then halt; > y:=2000; > m:=1; > d:=1; > w:=6; > while (ok(y)and(n>=366+365*3))or((not(ok(y)))and(n>=365*4)) do > begin > if ok(y) then > begin > w:=(366+365*3+w) mod 7; > if w=0 then w:=7; > dec(n,366+365*3); > end > else > begin > w:=(365*4+w) mod 7; > if w=0 then w:=7; > dec(n,365*4); > end; > inc(y,4); > end; > while ((ok(y))and(n>=366))or((not(ok(y)))and(n>=365)) do > begin > inc(y); > if ok(y) then > begin > w:=(366 mod 7+w) mod 7; > if w=0 then w:=7; > dec(n,366); > end > else > begin > w:=(365 mod 7+w) mod 7; > if w=0 then w:=7; > dec(n,365); > end; > end; > for i:=1 to n do > begin > w:=w mod 7+1; > if (m=2)and(ok(y)) then d:=d mod (c[m]+1)+1 > else d:=d mod c[m]+1; > if d=1 then m:=m mod 12+1; > if (m=1)and(d=1) then inc(y); > end; > write(y,'-'); > if m<10 then write('0',m,'-') > else write(m,'-'); > if d<10 then write('0',d,' ') > else write(d,' '); > writeln(p[w]); > end; > end. > 还是WA…… Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator