50,779
社区成员
发帖
与我相关
我的任务
分享
#include<bits/stdc++.h>
using namespace std;
int ff[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int y=1900,m=1,d=1,n,k=1;
int a[10];
int r()
{
int f=1,x=0;
char s = getchar();
while(s<'0'||s>'9')
{
if(s == '-')
{
f = -1;
}
s = getchar();
}
while(s>='0'&&s<='9')
{
x = x * 10 + s - '0';
s = getchar();
}
int num = x*f;
return num;
}
bool check(int n) {
if(n % 100 == 0) {
if(n % 400 == 0) return 1;
return 0;
}
if(n % 4 == 0) return 1;
return 0;
}
int main()
{
n = r();
while(y<=1900+n-1)
{
if(d==13)
{
a[k]++;
}
k++;
if(k>7)
{
k = 1;
}
d++;
if(d>(m==2?(check(y)?ff[m]+1:ff[m]):ff[m]))
{
m++;
d = 1;
}
if(m>12)
{
y++;
m = 1;
}
}
for(int i = 6; i <= 7; ++i)
{
cout<<a[i]<<" ";
}
for(int i = 1; i <= 5; ++i)
{
cout<<a[i]<<" ";
}
return 0;
}