20分----------qaq---------

P1067 [NOIP2009 普及组] 多项式输出

3~10WA
by nick_zha @ 2021-05-08 20:02:25


``` intput:99 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 1 8 output:-x^99-7x^50+100x^2+x+8 ``` 3数据点
by nick_zha @ 2021-05-08 20:03:48


40points,1/2/7/8 AC ``` #include<bits/stdc++.h> using namespace std; int a[105]; int main() { int b,g; cin>>b; for(int i=0;i<=b;i++) { cin>>a[i]; } if(a[0]>0) { if(a[0]==1){cout<<"x^"<<b;} else cout<<a[0]<<"x^"<<b; } else if(a[0]==0) { cout<<""; } else { if(a[0]==-1) { cout<<"-x^"<<b; } else cout<<a[0]<<"x^"<<b; } for(int i=1;i<=b;i++) { g=b-i; if(g==0) { if(a[i]!=0) { if(a>0){cout<<"+";} cout<<a[i]; } else(a[i]==0);{cout<<"";} } else if(g==1) { if(a[i]!=0) { if(a[i]>0){cout<<"+";} cout<<a[i]<<"x"; } else if(a[i]==0) { cout<<""; } } else { if(a[i]>0) { if(a[i]==1){cout<<"+x^"<<g;} else cout<<"+"<<a[i]<<"x^"<<g; } else if(a[i]==0) { cout<<""; } else { if(a[i]==-1) { cout<<"-x^"<<g; } else cout<<a[i]<<"x^"<<g; } } g=b-i; } return 0; } ```
by nick_zha @ 2021-05-15 20:46:49


50分[记录](https://www.luogu.com.cn/record/53881507) ```c #include<bits/stdc++.h> using namespace std; int a[105]; int main() { int b,g; cin>>b; for(int i=0;i<=b;i++) { cin>>a[i]; } if(a[0]>0) { if(a[0]==1){cout<<"x^"<<b;} else cout<<a[0]<<"x^"<<b; } else if(a[0]==0) { cout<<""; } else { if(a[0]==-1) { cout<<"-x^"<<b; } else cout<<a[0]<<"x^"<<b; } for(int i=1;i<=b;i++) { g=b-i; if(g==0) { if(a[i]!=0) { if(a>0){cout<<"+";} cout<<a[i]; } else(a[i]==0);{cout<<"";} } else if(g==1) { if(a[i]>0) { if(a[i]==1){cout<<"+x";} else cout<<"+"<<a[i]<<"x"; } else if(a[i]==0) { cout<<""; } else if(a[i]<0) { if(a[i]==-1){cout<<"-x";} else cout<<a[i]<<"x"; } } else { if(a[i]>0) { if(a[i]==1){cout<<"+x^"<<g;} else {cout<<"+"<<a[i]<<"x^"<<g;} } else if(a[i]==0) { cout<<""; } else if(a[i]<0) { if(a[i]==-1) { cout<<"-x^"<<g; } else cout<<a[i]<<"x^"<<g; } } g=b-i; } return 0; } ```
by nick_zha @ 2021-07-22 11:30:37


|