1 条题解

  • 0
    @ 2025-7-13 19:45:37

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    int n;
    cin>>n;
    for(int i=n;i>=0;i--)
    {
    	int x;
    	cin>>x;
    	if(x==0)	continue;
    	if(i!=n and x>0)	cout<<"+";
    	if(i==0)
    	{
    		cout<<x;
    		continue;
    	}
    	if(abs(x)!=1)		cout<<x;
    	if(x==-1)			cout<<"-";
    	if(i!=1)			cout<<"x^"<<i;
    	else				cout<<"x";
    
    }
    
    
    
    
    
    }
    
    
    
    • 1

    信息

    ID
    1981
    时间
    1000ms
    内存
    125MiB
    难度
    9
    标签
    递交数
    18
    已通过
    3
    上传者