fork download
  1. #include<bits/stdc++.h>
  2. #define ONLINE_JUGE
  3. #ifdef ONLINE_JUGE
  4. #ifdef _DEBUG
  5. #endif // _DEBUG
  6. #endif // ONLINE_JUGE
  7. #ifdef _DEBUG
  8. #define ll(x) << x
  9. #define ls ll(", ")
  10. #define ln(n, x) ll(n) ll(": ") ll(x) ls
  11. #define lv(x) ln(#x, x)
  12. #define pp(x) cout x ll(flush);
  13. #define pr(x) pp(ln("Line", __LINE__) x ll(endl))
  14. #define dbg1(x) x
  15. #else // _DEBUG
  16. #define ll(x)
  17. #define ls
  18. #define ln(n, x)
  19. #define lv(x)
  20. #define pp(x) ;
  21. #define pr(x) ;
  22. #define dbg1(x)
  23. #endif // _DEBUG
  24. using namespace std;
  25. #ifndef uint
  26. typedef unsigned int uint;
  27. #endif
  28.  
  29.  
  30. bool is_leap(uint y) {
  31. if (y % 400 == 0) {
  32. return true;
  33. } else if (y % 100 == 0) {
  34. return false;
  35. } else if (y % 4 == 0) {
  36. return true;
  37. } else {
  38. return false;
  39. }
  40. }
  41. /*
  42.  
  43.   January: 31 days
  44.   February: 28 days and 29 in every leap year
  45.   March: 31 days
  46.   April: 30 days
  47.   May: 31 days
  48.   June: 30 days
  49.   July: 31 days
  50.   August: 31 days
  51.   September: 30 days
  52.   October: 31 days
  53.   November: 30 days
  54.   December: 31 days
  55.  
  56. */
  57. bool is_valid(uint d, uint m, uint y) {
  58. if (m > 12) return false;
  59. if (m == 1) return d <= 31;
  60. else if (m == 2) return d <= (is_leap(y) ? 29 : 28);
  61. else if (m == 3) return d <= 31;
  62. else if (m == 4) return d <= 30;
  63. else if (m == 5) return d <= 31;
  64. else if (m == 6) return d <= 30;
  65. else if (m == 7) return d <= 31;
  66. else if (m == 8) return d <= 31;
  67. else if (m == 9) return d <= 30;
  68. else if (m == 10) return d <= 31;
  69. else if (m == 11) return d <= 30;
  70. else if (m == 12) return d <= 31;
  71. return true;
  72. }
  73.  
  74. int main() {
  75. uint d, m, y;
  76. cin >> d >> m >> y;
  77. if (is_valid(d, m, y)) {
  78. cout << "TAK" << "\n";
  79. } else {
  80. cout << "NIE" << "\n";
  81. }
  82. }
Success #stdin #stdout 0.01s 5284KB
stdin
3 6
1 -3
-10 1 2 1
1 1 3 2 -1 5 2 -3
stdout
TAK