标签:
题解:
模拟。
从1990~1990+n-1年之内,每一个月13号是星期几,累计一下就行了(注意:他是从六、日、一、二、三、四、五)。
{
ID:h1956701
LANG:PASCAL
PROB:friday
}
var n,s,i,j:longint;
day:array[1..12]of longint=(31,0,31,30,31,30,31,31,30,31,30,31);
a:array[0..11]of longint;
begin
assign(input,‘friday.in‘);
reset(input);
assign(output,‘friday.out‘);
rewrite(output);
readln(n);
s:=13;
for i:=1900 to 1900+n-1 do
begin
day[2]:=28;
if (i mod 400=0)or(i mod 4=0)and(i mod 100<>0) then inc(day[2]);
for j:=1 to 12 do
begin
s:=(s+day[j])mod 7;
inc(a[s]);
end;
end;
dec(a[s]);
write(a[6]+1,‘ ‘);
for i:=0 to 4 do write(a[i],‘ ‘);
writeln(a[5]);
close(input);
close(output);
end.
标签:
原文地址:http://www.cnblogs.com/huzhaoyang/p/5940792.html