Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
99785 王昭涵 多项式输出 C++ 通过 100 0 MS 252 KB 1076 2023-08-23 19:54:45

Tests(10/10):


#define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<cstdio> using namespace std; int t, xs, f{ 1 }, cnt; int main() { cin >> t; t++; while (t--) { scanf("%d", &xs); if (xs) ++cnt; if (f) { f = 0; if (xs == 1 && t == 1) printf("x"); else if (xs == -1 && t == 1) printf("-x"); else if (xs == 1) printf("x^%d", t); else if (xs == -1) printf("-x^%d", t); else if (xs) printf("%dx^%d", xs, t); continue; } if (!xs) continue; else { if (xs > 0 && cnt >= 2) printf("+"); if (xs != 1 && xs != -1 || !t) printf("%d", xs); else if (xs == -1) printf("-"); if (t == 1) printf("x"); else if (t > 1) printf("x^%d", t); } } return 0; }


测评信息: