usaco 1.1.3. Friday(黑色星期五)

发布于2022-01-13 07:05:10

我是pascal看看:var i,n,day,month,year:longint; a:array[1..7]of longint;begin readln(n); month:=1;year:=1900; for i:=1 to 7 do a[i]:=0; a[6]:=1;day:=6; for i:=2 to 12*n do begin inc(month); if month =13 then begin inc(year);month:=1;end; if month in[1,2,4,6,8,9,11] then day:=day+3; {month in when=the time from when-1 to when} if month in[5,7,10,12] then day:=day+2; if month=3 then if (year mod 400=0)or((year mod 4=0)and(year mod 100<>0)) then day:=day+1 else day:=day; if day>7 then day:=day mod 7; inc(a[day]); end; writeln(a[6],' ',a[7],' ',a[1],' ',a[2],' ',a[3],' ',a[4],' ',a[5]);end.

3个回答
admin
网友回答2022-01-13
program friday; const maxn=7; var top:integer; i,n,m,j,k:longint; a:array [1..maxn] of longint; procedure doit; begin if (top+12) mod 7=0 then a[7]:=a[7]+1 else a[(top+12) mod 7]:=a[(top+12) mod 7]+1; case j of 1,3,5,7,8,10,12:top:=(top+30) mod 7 +1; 4,6,9,11:top:=(top+29) mod 7 +1; 2:if k=1 then top:=(top+28) mod 7 +1 else top:=(top+27) mod 7 +1; end; end; begin top:=1; k:=0; readln(n); for i:=0 to n-1 do begin m:=i+1900; if m mod 100=0 then begin if m mod 400=0 then k:=1; end else if m mod 4=0 then k:=1; for j:=1 to 12 do doit; k:=0; end; write(a[6],' ',a[7],' '); for i:=1 to 4 do write(a[i],' '); writeln(a[5]); end.
admin
网友回答2022-01-13
if month in[5,7,10,12] then day:=day+2; if month=3 then if (year mod 400=0)or((year mod 4=0)and(year mod 100<>0)) then day:=day+1 else day:=day; if day>7 then day:=day mod 7;这好!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
admin
网友回答2022-01-13
这是一个运算式 建议你去下个实验实验 再看看别人怎么说的。

回到
顶部