C_0_a4S @ 2024-11-23 22:47:47
rt
#include <bits/stdc++.h>
using namespace std;
const int N=105;
int n;
int a[N];
int main(){
scanf("%d",&n);
for(int i=n;i>=0;i--){
scanf("%d",&a[i]);
}
if(n==0) cout<<a[0];
else{
for(int i=n;i>=0;i--){
if(i==n){
if(a[i]==0) continue;
if(a[i]==1){
putchar('x');
putchar('^');
printf("%d",i);
}
else if(a[i]==-1){
putchar('-');
putchar('x');
putchar('^');
printf("%d",i);
}
else{
printf("%d",a[i]);
putchar('x');
putchar('^');
printf("%d",i);
}
}
else if(i==1){
if(a[i]==0) continue;
if(a[i]<0){
if(a[i]==-1){
puts("-x");
}
else{
printf("%d",a[i]);
printf("x");
}
}
else{
if(a[i]==1) {
puts("+");
putchar('x');
}
else{
printf("+%d",a[i]);
putchar('x');
}
}
}
else if(i==0){
if(a[i]==0) continue;
if(a[i]<0){
printf("%d",a[i]);
}
else{
putchar('+');
printf("%d",a[i]);
}
}
else{
if(a[i]==0) continue;
if(a[i]<0){
if(a[i]==-1){
printf("-x^%d",i);
}
else{
printf("%dx^%d",a[i],i);
}
}
else{
if(a[i]==1) printf("+x^%d",i);
else{
printf("+%d",a[i]);
putchar('x');
putchar('^');
printf("%d",i);
}
}
}
}
}
return 0;
}