码迷,mamicode.com
首页 > 其他好文 > 详细

usaco Friday the Thirteenth

时间:2015-08-26 01:47:58      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:

/*
ID: modengd1
PROG: friday
LANG: C++
*/
#include <iostream>
#include <stdio.h>
#include <memory.h>
using namespace std;
int days[12]={31,29,31,30,31,30,31,31,30,31,30,31};
int N;
int counter[7];
bool isleap(int x)
{
    if((x%4)==0&&(x%100)!=0||((x%400)==0))
        return true;
    return false;
}
int main()
{
    freopen("friday.in","r",stdin);
    freopen("friday.out","w",stdout);
    scanf("%d",&N);
    memset(counter,0,sizeof(counter));
    long long day=1;
    for(int i=0;i<N;i++)
    {
        if(isleap(1900+i))
        {
            days[1]=29;
        }
        else
            days[1]=28;
        for(int j=0;j<12;j++)
        {
            counter[(day+13)%7]++;
            day+=days[j];
        }
    }
    cout<<counter[0];
    for(int i=1;i<7;i++)
        cout<<‘ ‘<<counter[i];
    putchar(‘\n‘);
    return 0;
}

  

usaco Friday the Thirteenth

标签:

原文地址:http://www.cnblogs.com/modengdubai/p/4759106.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!