@root

ykj48 流星雨 2024-07-22 19:45:30 6
#include <bits/stdc++.h>
using namespace std;
int a[110];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n+1;i++)
	{
		cin>>a[i];
	}
	int k=n;
	for(int i=1;i<=n+1;i++)
	{
		if(a[i]==0)
		{
			k--;
			continue;
		}
		if(k==0)
		{
			if(a[i]>=0 && i!=1) cout<<"+"<<a[i];
			else if(a[i]>=0 && i==1) cout<<a[i];
			else cout<<a[i];
		}
		else if(k==1)
		{
			if(a[i]==1) cout<<"+x";
			else if(a[i]==-1) cout<<"-x";
			else cout<<a[i]<<"x";
		}
		else 
		{
			if(a[i]==1)
			{
				if(i==1) cout<<"x^"<<k;
				else cout<<"+x^"<<k;
			}
			else if(a[i]==-1) cout<<"-x^"<<k;
			else
			{
				if(i==1) cout<<a[i]<<"x^"<<k;
				else if(a[i]>=0) cout<<"+"<<a[i]<<"x^"<<k;
				else if(a[i]<0) cout<<a[i]<<"x^"<<k;
			}
		}
		k--;
	}
	return 0;
}
{{ vote && vote.total.up }}