cambridge4090 @ 2024-07-11 21:01:18
#include<bits/stdc++.h>
using namespace std;
#define int long long
string a[105];
signed main()
{
int n;
cin>>n;
for(int i=0;i<=n;i++)
{
cin>>a[i];
}
int cnt=n;
for(int i=0;i<=n;i++)
{
if(cnt!=0&&a[i]!="-1"&&a[i]!="1"&&a[i]!="0")
{
if(a[i]>="0"&&i==0)
{
cout<<a[i]<<"x^"<<cnt;
}
else if(a[i]>="0"&&i!=0)
{
cout<<'+'<<a[i]<<"x^"<<cnt;
}
else
{
cout<<a[i]<<"x^"<<cnt;
}
}
else if(cnt!=0&&(a[i]=="-1"||a[i]=="1"))
{
if(a[i]=="-1")
{
cout<<"-x^"<<cnt;
}
else if(a[i]=="1"&&i!=0)
{
cout<<"+x^"<<cnt;
}
}
else if(a[i]!="0")
{
if(a[i]>="0")
cout<<'+'<<a[i];
else
cout<<a[i];
}
cnt--;
}
return 0;
}