Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
99437 | 刘星辰liuxingchen | 多项式输出 | C++ | 解答错误 | 40 | 0 MS | 236 KB | 1146 | 2023-08-22 18:30:13 |
#include<bits/stdc++.h> using namespace std; int n; int a[110]; string s; int main() { cin>>n; for(int i=1;i<=n+1;i++) { cin>>a[i]; } if(a[1]<0) { if(a[1]==-1) { cout<<"-"; cout<<"x"; cout<<"^"; cout<<n; } else { cout<<a[1]; cout<<"x"; cout<<"^"; cout<<n; } } else if(a[1]>=1) { if(a[1]==1) { cout<<"x"; cout<<"^"; cout<<n; } else { cout<<a[1]; cout<<"x"; cout<<"^"; cout<<n; } } for(int i=2;i<=n+1;i++) { if(i<=n) { if(a[i]>=1) { cout<<"+"; if(a[i]==1) { cout<<"x"; cout<<"^"; cout<<n-i+1; } else { cout<<a[i]; cout<<"x"; cout<<"^"; cout<<n-i+1; } } else if(a[i]<=-1) { if(a[i]==-1) { cout<<"-"; cout<<"x"; cout<<"^"; cout<<n-i+1; } else { cout<<a[i]; cout<<"x"; cout<<"^"; cout<<n-i+1; } } } else { if(a[i]>=1) { cout<<"+"; cout<<a[i]; } else { cout<<a[i]; } } } return 0; }