找规律递推。 AC代码: const int N = 5e5 + 50; int n, m, k; ll a[N]; int main() { int t; sd(t); a[1] = 0; for (ll i = 3, j = 1; i <= N - 10; i += 2, j++) a[i] = a[i - 2] + 4 * (i - 1) * j; while (t--) { sd(n); pld(a[n]); } return 0; }