14 solutions

  • 0
    @ 2024-2-20 0:03:56

    枚举前 3 个数,后 2 个数找下规律,开 O2 氧气优化,勉强可以 1s 以内暴力跑出结果。

    #pragma GCC optimize(2)
    #include <bits/stdc++.h>
    using namespace std;
    
    #define DBG(x) cout << #x << "=" << x << endl
    #define rep(i, k, n) for (int i = (k); i <= (n); ++i)
    
    using LL = long long;
    
    const int N = 2021;
    
    LL ans;
    
    // 答案:691677274345
    // 隔板法 2020C4
    void solve() {
      rep(a, 1, N - 4)
        rep(b, 1, N - a - 3)
          rep(c, 1, N - a - b - 2) {
            int de = N - a - b - c;
            if (de >= 2) {
              ans += de - 1;
            }
          }
    
      cout << ans << endl;
    }
    
    int main() {
      solve();
      // cout << "691677274345" << endl;
    
      return 0;
    }
    

    Information

    ID
    106
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    6
    Tags
    # Submissions
    504
    Accepted
    163
    Uploaded By