原題連結
真噁心
code
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=114514;
ll a[200005],d[200005];
bool solve()
{
ll n;
cin>>n;
for(ll i=1;i<=2*n;i++) cin>>d[i];
sort(d+1,d+1+2*n);
for(int i=2;i<=2*n;i+=2) if(d[i]%2||d[i]!=d[i-1]||d[i-2]==d[i-1]) return 0;//輸入正確
unique(d+1,d+1+2*n);
if(d[n]%(2LL*n)) return 0;
a[n]=d[n]/(2LL*n);
if(a[n]<=0) return 0;
ll sum=2LL*a[n];
for(ll i=n-1;i>=1;i--)
{
if((d[i]-sum)%(2LL*i)) return 0;
a[i]=(d[i]-sum)/(2LL*i);
if(a[i]==a[i+1]||a[i]<=0) return 0;//構造正確
sum+=2LL*a[i];
}
return 1;
}
int main()
{
int t=1;
cin>>t;
while(t--)
if(solve()) cout<<"yes\n";
else cout<<"no\n";
return 0;
}