fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. int c2[12] = {16, 18, 19, 25, 1, 2, 3, 4, 7, 8, 13, 14};
  7. int c3[4] = {21, 24, 27, 10};
  8.  
  9. int main (){
  10. int a, year1, year2, counter = 0;
  11. cin >> a;
  12. while (a--){
  13. cin >> year1 >> year2;
  14. for (int i = year1; i <= year2; i++){
  15. if (any_of(begin(c2), end(c2), [=](int n){return n == i%28;})) counter+=2;
  16. else if(any_of(begin(c3), end(c3), [=](int n){return n == i%28;})) counter+=3;
  17. else counter++;
  18. }
  19. }
  20. cout << counter;
  21. return 0;
  22. }
Success #stdin #stdout 0s 15232KB
stdin
4
1997 1999
1967 1972
2032 2032
1930 1933
stdout
24