Advertisement
makut

Meow 1

Apr 7th, 2016
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. # include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. bool is_vis(int y)
  6. {
  7.     return (y % 4 == 0 && y % 100 != 0) || (y % 400 == 0);
  8. }
  9.  
  10. int main()
  11. {
  12.     int d;
  13.     cin >> d;
  14.     int curr[3];
  15.     curr[2] = d % 10000;
  16.     d /= 10000;
  17.     curr[1] = d % 100;
  18.     d /= 100;
  19.     curr[0] = d;
  20.     int n = 1;
  21.     while (!(curr[0] == 1 && curr[1] == 1 && curr[2] == 1))
  22.     {
  23.         n++;
  24.         curr[0]--;
  25.         if (curr[0] == 0)
  26.         {
  27.             if (curr[1] == 3 && is_vis(curr[2]))
  28.             {
  29.                 curr[0] = 29;
  30.                 curr[1] = 2;
  31.             }
  32.             else if (curr[1] == 3)
  33.             {
  34.                 curr[0] = 28;
  35.                 curr[1] = 2;
  36.             }
  37.             else if (curr[1] == 1)
  38.             {
  39.                 curr[0] = 31;
  40.                 curr[1] = 12;
  41.                 curr[2]--;
  42.             }
  43.             else if (curr[1] == 4 || curr[1] == 6 || curr[1] == 8 || curr[1] == 9 || curr[1] == 11 || curr[1] == 2)
  44.             {
  45.                 curr[0] = 31;
  46.                 curr[1]--;
  47.             }
  48.             else
  49.             {
  50.                 curr[0] = 30;
  51.                 curr[1]--;
  52.             }
  53.         }
  54.     }
  55.     cout << n;
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement