Untitled
unknown
plain_text
20 days ago
2.0 kB
4
Indexable
Never
#include <bits/stdc++.h> using namespace std; vector<int> lethal; bool isLeapYear(int year) { if (year % 400 == 0) { return true; } if (year % 100 == 0) { return false; } if (year % 4 == 0) { return true; } return false; } int daysInMonth(int month, int year) { if (month == 2) { if (isLeapYear(year)) { return 29; } return 28; } if (month == 4 || month == 6 || month == 9 || month == 11) { return 30; } return 31; } int main() { long long a,b,c,d,tt=0,cx=0,tl=0; int xmax; cin >> a>>b>>c>>d; while (c<d) { tt++; cx++; tl++; if (tt==28) tt=0; if (cx==34) cx=0; if (tl== 24) tl=0; xmax=daysInMonth(b,c); a++; if (a==xmax) { a=1; b++; if (b==13) { b=1; c++; } } } long long i=c+1,dem1=0,dem2=0; while(c<i) { dem1++; dem2=0; tt++; cx++; tl++; if (tt==28) { tt=0; dem2++; } if (cx==34) { cx=0; dem2++; } if (tl== 24) { tl=0; dem2++; } if (dem2>=2) { lethal.push_back(dem1); } xmax=daysInMonth(b,c); a++; if (a==xmax) { a=1; b++; if (b==13) { b=1; c++; } } } if (lethal.empty()) { cout << "Lucky"; } else { for (int i=0; i<=lethal.size()-1; i++) { cout << lethal[i]<<" "; } } return 0; }
Leave a Comment