usaco 1.1.3.Friday(黑色星期五)

学习 时间:2026-04-07 21:08:30 阅读:3135
usaco 1.1.3.Friday(黑色星期五)我是pascal看看:var i,n,day,month,year:longint;a:array[1..7]of longint;beginreadln(n);month:=1;year:=1900;for i:=1 to 7 doa[i]:=0;a[6]:=1;day:=6;for i:=2 to 12*n dobegininc(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 thenif (year mod 400=0)or((year mod 4=0)and(year mod 1000)) thenday:=day+1else 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.

最佳回答

风中的柠檬

体贴的金针菇

2026-04-07 21:08:30

program friday;constmaxn=7;vartop:integer;i,n,m,j,k:longint;a:array [1。。maxn] of longint;procedure doit;beginif (top+12) mod 7=0then a[7]:=a[7]+1else a[(top+12) mod 7]:=a[(top+12) mod 7]+1;case j of1,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=1then top:=(top+28) mod 7 +1else top:=(top+27) mod 7 +1;end;end;begintop:=1;k:=0;readln(n);for i:=0 to n-1 dobeginm:=i+1900;if m mod 100=0then beginif m mod 400=0then k:=1;endelse if m mod 4=0then k:=1;for j:=1 to 12 dodoit;k:=0;end;write(a[6],' ',a[7],' ');for i:=1 to 4 dowrite(a[i],' ');writeln(a[5]);end。

最新回答共有2条回答

  • 妩媚的摩托
    回复
    2026-04-07 21:08:30

    program friday;constmaxn=7;vartop:integer;i,n,m,j,k:longint;a:array [1。。maxn] of longint;procedure doit;beginif (top+12) mod 7=0then a[7]:=a[7]+1else a[(top+12) mod 7]:=a[(top+12) mod 7]+1;case j of1,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=1then top:=(top+28) mod 7 +1else top:=(top+27) mod 7 +1;end;end;begintop:=1;k:=0;readln(n);for i:=0 to n-1 dobeginm:=i+1900;if m mod 100=0then beginif m mod 400=0then k:=1;endelse if m mod 4=0then k:=1;for j:=1 to 12 dodoit;k:=0;end;write(a[6],' ',a[7],' ');for i:=1 to 4 dowrite(a[i],' ');writeln(a[5]);end。

上一篇 屁股用英语怎么说

下一篇 我的感想400字作文