#include<iostream>
using namespace std;
int n, a[101];
void start()
{
cin >> n;
for (int i = 0; i <= n; i++)
cin >> a[i];
}
void show()
{
if (0 == n)
cout << a[0];
else
for (int x = 0; x <= n; x++)
if (a[x] > 0)
if (x != 0)
{
if (1 == a[x] && n != x)
cout << '+';
else
cout << '+' << a[x];
if (n - 1 == x)
cout << 'x';
else if (n != x)
cout << 'x' << '^' << n - x;
}
else
{
if (1 != a[x])
cout << a[x];
if (n - 1 == x)
cout << 'x';
else if (n != x)
cout << 'x' << '^' << n - x;
}
else if (a[x] < 0)
{
if (-1 == a[x]&&n!=x)
cout << '-';
else
cout << a[x];
if (n - 1 == x)
cout << 'x';
else if (n != x)
cout << 'x' << '^' << n - x;
}
}
int main()
{
start();
show();
return 0;
}
洛谷P1067 [NOIP2009 普及组] 多项式输出进阶解法
最新推荐文章于 2024-07-04 09:29:02 发布