基于链表的一元多项式的基本运算
代码不知道哪里有缺陷交到OJ上一直Wrong Answer,走投无路记到这里希望哪位大佬走过路过能留意一下子呜呜呜
题目

输入输出样例
输入样例
4
1 1
1 0
1 1
+
4 3
7 0
3 1
9 8
5 17
8 1
22 7
-9 8
+
1 1
1 1
1 1
-
1 1
1 1
1 1
'
输出样例
1x^1+1
5x^17+22x^7+11x^1+7
0
1
1
详细情况说明
样例是过了的,测试了一些其他特殊情况例如只有一项常数项求导、其中一个多项式为0、相加之后全部为0或只剩常数等等,这些都没什么问题,但是交上去之后一直是Wrong Answer。
实在没办法了救救孩子吧呜呜呜。
贴代码(当然有注释)
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#define MAXN (int)1e5
using namespace std;
struct Elem{
int num=0;
int idx=0;
Elem *next=NULL;
};
Elem *ahead=new Elem();
Elem *bhead=new Elem();
void Sort(Elem *head) {
if(head->next==NULL||head->next->next==NULL) return ;
Elem* p,*q;
Elem* h=head;
Elem* t;
t=NULL;
while ((<


6583

被折叠的 条评论
为什么被折叠?



