本蒟蒻用递推式写的,试了几个小样例都对的,但交上去全WA,有大佬帮忙看看嘛
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 10;
long long q, x;
long long num[maxn], sum[maxn];
void prepare() {
for (int i = 1; i <= 1e4; i++) {
num[i] = pow(i, 3);
}
for (int i = 1; i <= 1e4; i++) {
sum[i] = sum[i - 1] + (i - 1) * (3 * i * i - 3 * i + 1);
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
prepare();
cin >> q;
while (q--) {
cin >> x;
int k = floor(pow(x, 1 / 3.0));
long long ans = sum[k] + k * (x - num[k] + 1);
cout << ans << endl;
}
return 0;
}