P1067 [NOIP2009 普及组] 多项式输出
30% WA
#include <bits/stdc++.h>
using namespace std;
int a[1001];
int main(){
int n;
cin >> n;
for (int i = 1; i <= n + 1; i++)
cin >> a[i];
int k = n + 1;
for (int i = 1; i <= n + 1; i++){
k--;
if (a[i] > 0 && i != 1)
cout << "+";
if (a[i] == -1)
cout << "-";
if (a[i] == 0)
continue;
if (a[i] != 1 && a[i] != -1)
cout << a[i];
if (k > 1)
cout << "x^" << k;
}
return 0;
}