jiang_yitao @ 2024-09-24 20:45:09
WA #1 #4
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >>n;
if(n==1) {
int q;
cin >>q;
cout<<q;
return 0;
}
if (n==2) {
int z,e;
cin >> z>>e;
if (z!=0) {
if(z!=1&&z!=-1){
cout<<z<< "x";
}else {
if (z<0) cout<<'-';
cout<<"x";
}
}
if (e!=0) {
if(e!=0) {
if (e>0) cout<<'+';
cout <<e;
}
}
return 0;
}
int z;
cin >> z;
if(z!=1&&z!=-1){
cout<<z<< "x^"<<n;
}else {
if (z<0) cout<<'-';
cout<<"x^"<<n;
}
for(int i=n-1;i>=2;i--) {
int q;
cin >>q;
if(q==0) continue;
if (q>0) cout<<'+';
if(q!=1&&q!=-1){
cout<<q<< "x^"<<i;
}else {
if (q<0) cout<<'-';
cout<<"x^"<<i;
}
}
int w,e;
cin >>w>>e;
if(w!=0) {
if (w>0) cout<<'+';
cout <<w<<"x";
}
if(e!=0) {
if (e>0) cout<<'+';
cout <<e;
}
return 0;
}
by 大眼仔Happy @ 2024-09-24 21:00:34
@jiang_yitao
4
1 3 2 1 6
by jiang_yitao @ 2024-09-24 21:02:01
@大眼仔Happy 谢谢大佬指点(已关