Advertisement
Dmaxiya

艺术与篮球 参考代码

Mar 29th, 2025
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long LL;
  5. const int maxn = 100 + 100;
  6. int ans;
  7. int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  8. int bihua[10] = {13, 1, 2, 3, 5, 4, 4, 2, 2, 2};
  9.  
  10. int cal(int x, int dig) {
  11.     int ret = 0;
  12.     for (int i = 0; i < dig; ++i) {
  13.         ret += bihua[x % 10];
  14.         x /= 10;
  15.     }
  16.     return ret;
  17. }
  18.  
  19. int main() {
  20. #ifdef ExRoc
  21.     freopen("test.txt", "r", stdin);
  22. #endif // ExRoc
  23.     ios::sync_with_stdio(false);
  24.  
  25.     for (int year = 2000; year <= 2024; ++year) {
  26.         if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) {
  27.             days[2] = 29;
  28.         } else {
  29.             days[2] = 28;
  30.         }
  31.         int maxMonth = (year == 2024 ? 4 : 12);
  32.         for (int month = 1; month <= maxMonth; ++month) {
  33.             int maxDay = (year == 2024 && month == 4 ? 13 : days[month]);
  34.             for (int day = 1; day <= maxDay; ++day) {
  35.                 if (cal(year, 4) + cal(month, 2) + cal(day, 2) > 50) {
  36.                     ++ans;
  37.                 }
  38.             }
  39.         }
  40.     }
  41.     cout << ans << endl;
  42.  
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement