发现可以O(N^2) 然后可以边做边处理两个宝石的乘积,然后另一个可以直接查hash
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define int long long
const int N = 1e5+10;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int qmi(int a,int b,int mod){int res=1;while(b){if(b&1)res=res*a%mod;b>>=1;a=a*a%mod;}return res;}
int n,q,m;
// int e[N],ne[N],w[N],h[N],idx;
// void add(int a,int b,int c){
// e[idx] = b,ne[idx] = h[a],w[idx] = c,h[a] = idx++;
// }
int a[N];
unordered_map<int,bool>vis;
void solve()
{
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
int ans = 0;
for(int i=n;i>=1;--i){
if(!a[i]&&vis[0]){
ans++;
continue;
}
for(int j=n;j>i;--j){
if(a[j]&&a[i]%a[j]==0&&vis[a[i]/a[j]]){
ans++;
break;
}
}
for(int j=n;j>=i;--j)vis[a[i]*a[j]] = true;
}
cout<<ans;
}
signed main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int _;
//cin>>_;
_ = 1;
while(_--)solve();
return 0;
}