UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212557#3839. 小t爱算数(mul)ChenHanzhangCompile Error//C++571b2024-10-19 11:25:132024-10-19 12:35:16

answer

#include<bits/stdc++.h>
using namespace std;
map<int,int>a;
map<int,int>b;
int main(){
	int x,y,maxn=INT_MIN,maxm=INT_MIN;
	while(cin>>x){
		if(x==-1) break;
		cin>>y;
		a[x]+=y;
		maxn=max(maxn,x);
	}
	while(cin>>x){
		if(x==-1) break;
		cin>>y;
		maxm=max(maxm,x);
		for(auto &&i:a) b[i.first+x]+=i.second*y;
	}
	for(int i=maxn+maxm;i>=0;i--){
		if(b[i]==0) continue;
		if(i==maxn+maxm){
			cout<<b[i];
			if(i!=0) cout<<"x^"<<i;
		}else{
			if(b[i]>0) cout<<"+";
			cout<<b[i];
			if(i!=0) cout<<"x^"<<i;
		}
	}
	cout<<endl;
	return 0;
}

详细

answer.code: In function 'int main()':
answer.code:17:12: error: expected unqualified-id before '&&' token
   for(auto &&i:a) b[i.first+x]+=i.second*y;\x0d
            ^
answer.code:17:12: error: expected ';' before '&&' token
answer.code:17:15: error: expected ';' before ':' token
   for(auto &&i:a) b[i.first+x]+=i.second*y;\x0d
               ^
answer.code:17:15: error: expected primary-expression before ':' token
answer.code:17:15: error: expected ')' before ':' token
answer.code:17:15: error: expe...