CodeForces - 1081E Missing Numbers (平方数,构造)
程序员文章站
2022-03-19 15:02:16
...
???????? ???????? ????????
假设我们已经构造出了前2i - 2项,目前构造第 2i - 1项,而2i项已知,我们新插入的2i-1项要与他们满足如下关系
#define int ll
int v[MX];
signed main()
{
int n;cin>>n;
n>>=1;
memset(v,-1,sizeof(v));
rpp(i,n) cin>>v[i*2];
int now=0;
rpp(i,n)
{
int y=v[i*2];
for(int _=1;_*_<=y;++_)//下划线派qwq
{
if(y%_==0&&((y/_+_)%2==0)&&((y/_-_)%2==0))
{
int a=(y/_-_)/2;
if(a*a<=now) continue;
if(v[i*2-1]==-1) v[i*2-1]=a*a-now;
else v[i*2-1]=min(v[i*2-1],a*a-now);
}
}
if(v[i*2-1]==-1)
{
cout<<"No\n";
stop;
return 0;
}
now+=v[i*2-1]+v[i*2];
}
n<<=1;
cout<<"Yes\n";
rpp(i,n) cout<<v[i]<<" ";
cout<<endl;
stop;
return 0;
}