提交时间:2023-08-22 16:59:57

运行 ID: 99421

#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; bool first = true; for (int i = n; i >= 0; i--) { int x; cin >> x; if (x == 0) continue; if (!first && x >= 1) cout << "+"; first = false; if (x == -1 && i != 0) cout << "-"; if (abs(x) != 1 || i == 0) cout << x; if (i != 0) cout << "x"; if (i > 1) cout << "^" << i; } return 0; }