Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 1000000;
- bool isLeap(int n)
- {
- if(n%400==0) return true;
- if(n%100==0) return false;
- if(n%4==0) return true;
- return false;
- }
- int main()
- {
- map< int, int > days;
- days[1] = days[3] = days[5] = days[7] = days[8] = days[10] = days[12] = 3;
- days[4] = days[6] = days[9] = days[11] = 2;
- days[2] = 0;
- int curr = 2;
- int ans = 0;
- for(int i=1901; i<=2000; i++) {
- for(int j=1; j<=12; j++) {
- if(curr%7==0) {
- // cout << i << " " << j << "\n";
- ans++;
- }
- // cout << i << " " << j << " " << curr << "\n";
- int dd = days[j];
- if(j==2 && isLeap(i)) {
- // cout << "Leap year: " << i << "\n";
- dd++;
- }
- curr += dd;
- // curr %= 8;
- }
- }
- cout << ans << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement