记录编号 550188 评测结果 AAAAAAAAAA
题目名称 [NOIP 2009PJ]多项式输出 最终得分 100
用户昵称 Gravatar锝镆氪锂铽 是否通过 通过
代码语言 C++ 运行时间 0.000 s
提交时间 2020-03-04 11:56:22 内存使用 0.00 MiB
显示代码纯文本
#include<iostream>
#include<cstdio>
using namespace std;

int pol(){
	freopen("poly.in","r",stdin);
	freopen("poly.out","w",stdout);
	int n,num,t=0;
	{
	scanf("%d",&n);
	for(int i=n;i>=0;i--){
		scanf("%d",&num);
		if(i==0){
			if(num>0)
				printf("+%d",num);
			else if(num<0)
				printf("%d",num);
			break;
		}
		if(i==1){
			if(num==0)
				continue;
			else
				if(num>1)
					printf("+%dx",num);
				else if(num!=-1&&num!=1)
					printf("%dx",num);
				else
					if(num==1)
						printf("+x");
					else
						printf("-x");
			continue;
		}
		if(i!=n&&num>1){
			printf("+%dx^%d",num,i);
			continue;
		}
		if(num==0)
			continue;
		if(i==n&&num>1){
			printf("%dx^%d",num,i);
			continue;
		}
		if(num!=1&&num!=-1){
			printf("%dx^%d",num,i);
			continue;
		}
		if(num==-1){
			printf("-x^%d",i);
			continue;
		}
		if(num==1&&i!=n){
			printf("+x^%d",i);
			continue;
		}
		if(i==n&&num==1){
			printf("x^%d",i);
			continue;
		}
		t++;
	}
	//printf("\n%d\n",t);
	}//while(1);
	return 0;
}

int lol=pol();
int main(void){;}