-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.cpp
More file actions
79 lines (66 loc) · 1.91 KB
/
main.cpp
File metadata and controls
79 lines (66 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,b) for(int i=0;i<b;i++)
#define all(v) v.begin(),v.end()
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort(v.rbegin(),v.rend())
#define REV(v) reverse(v.begin(),v.end())
#define INF 2147483647
#define MOD 998244353
#define MAX 1000005
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> pii;
typedef pair<ll, ll> LL;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int setBit(int mask, int pos){return mask = mask | (1<<pos);}
bool checkBit(int mask, int pos){return (bool)(mask & (1<<pos));}
void solve() {
int n, ans = 0;
cin>>n;
for(int i = 0; i <= n; i++) {
int sum = 0, mx = 0;
for (int j = 1; j <= i; j++) {
sum += j * j;
mx = max(mx, j * j);
}
int curr = n;
for (int j = i + 1; j <= n; j++) {
sum += j * curr;
mx = max(mx, j * curr);
curr--;
}
ans = max(ans , sum - mx);
}
cout<<ans<<endl;
return;
}
int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int test = 1;
cin>>test;
while(test--) {
solve();
}
return 0;
}