#include <iostream> #include <fstream> #include <string> #include <vector>
using namespace std;
class Checker { public: int day, year, offset;
Checker() : day(1), year(1900), offset(1) { frequentCounterList = {0, 0, 0 , 0, 0, 0, 0, 0}; month2days = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; }
void traverse(int n) { for (int i = 0; i < n; ++i) { for (int month = 1; month <= 12; ++month) { day = offset + 12; frequentCounterList[day % 7 + 1]++;
if (month == 2) { if (isLeapYear(year)) offset += 29; else offset += 28; } else offset += month2days[month]; } ++year; } }
vector<int> getFrequency() const { return frequentCounterList; }
private: vector<int> frequentCounterList; vector<int> month2days;
private: bool isLeapYear(int year) { if (year % 100 == 0) return year % 400 == 0;
return year % 4 == 0; }; };
int main() { ofstream fout ("friday.out"); ifstream fin ("friday.in");
string years; getline(fin, years); Checker checker; checker.traverse(stoi(years));
auto list = checker.getFrequency(); fout << list[7] << " " << list[1] << " " << list[2] << " " << list[3] << " " << list[4] << " " << list[5] << " " << list[6] << endl;
return 0; }
|