其他分享
首页 > 其他分享> > USACO Friday the Thirteenth

USACO Friday the Thirteenth

作者:互联网

题目过于简单

用一个变量cday去表示当前日子,cday为0代表星期天

/*
ID: kdk5501
TASK : friday
LANG : C++
*/

#include <iostream>
#include <fstream>
#include <string>

using namespace std;
struct people
{
    string name;
    int money;
}person[110];


int main() 
{    

    int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    int ans[8]={0,0,0,0,0,0,0,0};
    freopen("friday.in","r",stdin);
    freopen("friday.out","w",stdout);
    int n;
    cin>>n;
    bool st=false;
    int cday=1;
    for(int i=1900;i<=1900+n-1;i++)
    {
        st=false;
        if((i%4==0&&i%100!=0)||i%400==0)
        {
            st=true;
            day[2]++;
        }
        for(int j=1;j<=12;j++)
        {    
            ans[(cday+12)%7]++;
            cday=(cday+day[j])%7;
        }

        if(st==true)
        {
            day[2]--;
        }
    }

    cout<<ans[6]<<" "<<ans[0]<<" ";
    for(int i=1;i<=5;i++)
    {
        cout<<ans[i];
        if(i!=5)    cout<<" ";
    }
    cout<<endl;
    return 0;
}

 

标签:Friday,friday,Thirteenth,int,31,30,USACO,cday,include
来源: https://www.cnblogs.com/magicat/p/15630782.html