1 solutions
-
0
C++ :
#include <bits/stdc++.h> using namespace std; int month[15]={0,31,28,31,30,31,30,31,31,30,31,30,31}; int n,countt[8],day; int main() { day=6; cin>>n; for(int i=1900;i<=1900+n-1;i++) { for(int j=1;j<=12;j++) { countt[day]++; if(j==2 && i%4==0 && i%100!=0 || i%400==0 && j==2)day=(day-1+1)%7+1; day=(day-1+month[j])%7+1; } } cout<<countt[6]<<" "<<countt[7]<<" "; for(int i=1;i<=5;i++) cout<<countt[i]<<" "; return 0; }Pascal :
const a:array[1..12] of integer=(31,28,31,30,31,30,31,31,30,31,30,31); var n,i,j,t:longint; b:array[0..6] of longint; begin readln(n); t:=0; for i:=1900 to 1900+n-1 do begin if(i mod 400=0)or(i mod 4=0)and(i mod 100<>0) then a[2]:=29 else a[2]:=28; for j:=1 to 12do begin inc(b[(t+13)mod 7]); inc(t,a[j]); end; end; writeln(b[6],' ',b[0],' ',b[1],' ',b[2],' ',b[3],' ',b[4],' ',b[5]) ; end.
- 1
Information
- ID
- 18024
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By