Untitled
unknown
plain_text
2 years ago
720 B
6
Indexable
#define ll long long
#define pb push_back
#define ipar(arr, n) vector<ll> arr(n); for(int i=0;i<n;i++) cin>>arr[i];
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
ll fact(ll n){
ll ans=1;
while(n>1){
ans*=n;
n--;
}
return ans;
}
ll choose(ll n,ll c){
if(c<0 || c>n) return 1;
return fact(n)/(fact(c)*fact(n-c));
}
void solve(){
ll n;cin>>n;
ll fla=0;
if(n>=2) fla+=n*(n-1)*(n-1)*2; //pattern 1 and 2
if(n>=3) fla+=n*(n-1)*(n-2);//pattern 3
if(n>=3) fla+=n*(n-1)*(n-2)*(n-2)*2; //pattern 4 and 5
cout<<fla<<"\n";
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int t;
cin>>t;
while(t--) solve();
}
Editor is loading...
Leave a Comment