USACO黑色星期五
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了USACO黑色星期五相关的知识,希望对你有一定的参考价值。
#include<bits/stdc++.h>
using namespace std;
int judge(int year)
{
if(year%4==0&&year%100||year%400==0)
return 1;
return 0;
}
int run[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int ping[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int week[7]={0,0,0,0,0,0,0};
int main()
{
int numyear,sumdays=0;
int i,j;
cin>>numyear;
for(i=1900;i<1900+numyear;i++)
{
if(judge(i))
{
for(j=1;j<=12;j++)
{
sumdays+=13;
week[sumdays%7]++;
sumdays+=(run[j]-13);
}
}
else
{
for(j=1;j<=12;j++)
{
sumdays+=13;
week[sumdays%7]++;
sumdays+=(ping[j]-13);
}
}
}
cout<<week[6]<<‘ ‘;
for(i=0;i<6;i++) cout<<week[i]<<‘ ‘;
cout<<endl;
return 0;
}
以上是关于USACO黑色星期五的主要内容,如果未能解决你的问题,请参考以下文章
P1202 [USACO1.1]黑色星期五Friday the Thirteenth