Club Competition T3 Square:
LHY:
#include <bits/stdc++.h>
using namespace std;
unsigned long long a[2 * 10000 + 10];
int pc(int n,int m){
int cnt=0;
while(n<m){
n*=n;
cnt++;
}return cnt;
}
int main(){
//freopen("i.txt","r",stdin);
//freopen("o.txt","w",stdout);
int q;
cin >> q;
while(q--){
int n,cnt=0;
cin >> n;
for(int i=0;i<n;i++) cin >> a[i];
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
cnt+=pc(a[j],a[i]);
}
}
cout << cnt << endl;
}
return 0;
}
// by click
JSGF:
#include<bits/stdc++.h>
#define int unsigned long long
using namespace std;
int a[3000005];
signed main(){
freopen("square.in","r",stdin);
// freopen("square.out","w",stdout);
int q;
cin>>q;
while(q--){
int n,cnt=0;
cin>>n;
for(int i=1;i<=n;i++){cin>>a[i];}
for(int i=n;i>=1;i--){
for(int j=n;j>=i+1;j--){
if(a[i]<a[j]){cnt++;}
}
}
cout<<cnt<<'\n';
}
return 0;
}