提交时间:2023-08-22 22:49:16

运行 ID: 99525

#include <bits/stdc++.h> using namespace std; int arr[100005]; int main(){ int n; cin>>n; for(int i = 0;i<=n;i++){ cin>>arr[i]; } int m = n; for(int i = 0;i<=n&&m>=0;i++){ if(arr[i]==0){ m--; continue; } else if(arr[i]>0){ if(n!=m){ cout<<"+"; } if (arr[i]!=1) { cout << arr[i]; } if(m==0){ if (arr[i]==1) cout << "1"; } else { cout << "x"; if (m>1) cout << "^" << m; } } else{ if (arr[i]!=-1) { cout << arr[i]; } else{ cout<<"-"; } if(m==0){ if(arr[i]==-1) cout<<"1"; } else { cout << "x"; if (m>1) cout << "^" << m; } } m--; } cout<<endl; return 0; }