https://codeforces.com/gym/457091/problem/G
作者:
断剑起舞为佳人
,
2023-07-18 21:52:28
,
所有人可见
,
阅读 166
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
typedef long long LL;
const int N = 1e3+5;
unordered_map<LL, pair<int, int >> asd;
unordered_map<pair<int, int >, LL> qwe;
LL ans[N][N];
int main()
{
int t;
cin >> t;
for (int i = 1; i <= 1000; i++)
{
ans[i][0] = (i * i - 3 * i + 2) / 2;
for (int j = 1,tem=i; j <= 1000; j++,tem++)
{
ans[i][j] = ans[i][j - 1] + tem;
LL x = ans[i][j];
asd[x] = { i,j };
if (j > 1)
{
qwe[{i, j}] = qwe[{i, j - 1}] + x * x;
}
else
qwe[{i, j}] = x * x;
}
}
while (t--)
{
int n;
cin >> n;
int x = asd[n].first, y = asd[n].second;
cout << qwe[{x, y}] << endl;
}
return 0;
}