Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _USE_MATH_DEFINES
- #include<stdio.h>
- #include<iostream>
- #include<vector>
- #include<cmath>
- #include<algorithm>
- #include<map>
- #include<set>
- #include<sstream>
- #include<cstring>
- #include<numeric>
- #include<limits.h>
- using namespace std;
- int c[12]{
- 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
- };
- map<int, vector<int>> res;
- string name[7]{
- "mon", "tue", "wed", "thu", "fri", "sat", "sun"
- };
- int main() {
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin);
- #endif
- int s = 5;
- int d, m, y;
- scanf("%d%d%d", &d, &m, &y);
- int start = -1;
- for (int i = 1600; i <= y; i++) {
- for (int j = 1; j <= 12; j++) {
- int delta = 0;
- if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) {
- if (j == 2) {
- delta++;
- }
- }
- for (int z = 1; z <= c[j - 1] + delta; z++) {
- if (y == i && j == m) {
- if (start == -1)
- start = s;
- res[s].push_back(z);
- }
- s++;
- s %= 7;
- }
- }
- }
- for (auto i : res) {
- printf("%s", name[i.first].c_str());
- bool prev = false;
- if (i.second.size() == 5 && (*i.second.rbegin() == 30 || *i.second.rbegin() == 31)) {
- if (start > i.first) {
- if (i.first == 0 || i.first == 1) {
- printf(" ");
- }
- }
- }
- if (i.second.size() != 5) {
- if(start > i.first)
- printf(" ");
- }
- for (auto j : i.second) {
- if (j / 10 == 0 && j != i.second[0])
- printf(" ");
- if (j == d) {
- if (j / 10 == 0) {
- printf(" [ %d]", j);
- }
- else {
- printf(" [%d]", j);
- }
- prev = true;
- }
- else {
- if (!prev)
- printf(" ");
- else {
- prev = false;
- }
- printf(" %d", j);
- }
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement