您的位置:首页 > 其它

USACO Section 1.1: Friday the Thirteenth

2014-03-10 05:33 281 查看
/*
ID: leetcod3
PROG: friday
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <algorithm>
#include <stdio.h>
#include <queue>
#include <cstring>
#include <cmath>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <limits>
#include <stack>

using namespace std;

ofstream fout ("friday.out");
ifstream fin ("friday.in");

bool leap(int year) {
return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
}

int main() {
int N;
fin >> N;
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int day = 0;
vector<int> days(7);
for (int i = 1900; i < 1900 + N; i++) {
for (int j = 0; j < 12; j++) {
days[(day + 12) % 7]++;
if (j == 1) day += (leap(i)? 29 : 28);
else day += month[j];
}
}
fout << days[5] << " " << days[6] << " ";
for (int i = 0; i < 4; i++) fout << days[i] << " ";
fout << days[4] << endl;
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: