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 |
同情...感觉最e的就是日历的题目了In Reply To:悲哀……对着日历都对过了,结果还是WA Posted by:realmajia at 2005-06-04 02:59:12 > 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 n>=366+365*3 do > begin > inc(y,4); > w:=(366+365*3+w) mod 7; > if w=0 then w:=7; > dec(n,366+365*3); > 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. Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator