UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212523#3839. 小t爱算数(mul)xiaoxueshenCompile Error//C++1.2kb2024-10-19 10:41:232024-10-19 12:33:50

answer

#include<bits/stdc++.h>
using namespace std;
struct xs{
	int xi;
	int zh;
}dxs1[1000+10],dxs2[1000+10],dxs3[2000+10];
unordered_map<int,int> ds1,ds2,ds3;
bool cmp(xs a,xs b)
{
	return a.zh>b.zh;
}
int main()
{
	int a,b;
	char c;
	while(scanf("%d%c",&a,&c)==2&&!(c=='\n'&&a==-1))
	{
		scanf("%d",&b);
		ds1[a]+=b;
		scanf(" ");
	}
	while(scanf("%d%c",&a,&c)==2&&!(c=='\n'&&a==-1))
	{
		scanf("%d",&b);
		ds2[a]+=b;
		scanf(" ");
	}
	int s1=0;
	for (auto& n : ds1) {
		s1++;
   		dxs1[s1].xi=n.second;
   		dxs1[s1].zh=n.first;
	}
	int s2=0;
	for (auto& n : ds2) {
		s2++;
   		dxs2[s2].xi=n.second;
   		dxs2[s2].zh=n.first;
	}
	for(int i=1;i<=s1;i++)
	{
		for(int j=1;j<=s2;j++)
		{
			ds3[dxs1[i].zh+dxs2[j].zh]+=dxs1[i].xi*dxs2[j].xi;
		}
	}
	int s3=0;
	for (auto& n : ds3) {
		s3++;
   		dxs3[s3].xi=n.second;
   		dxs3[s3].zh=n.first;
	}
	sort(dxs3+1,dxs3+s3,cmp);
	for(int i=1;i<=s3;i++)
	{
		if(i!=1&&dxs3[i].xi>=0)	cout<<'+';
		if(dxs3[i].xi==0)
		{
			
		}
		else if(dxs3[i].zh==0)
		{
			cout<<dxs3[i].xi;
		}
		else if(dxs3[i].xi==1)
		{
			cout<<"x^"<<dxs3[i].zh;
		}
		else
		{
			cout<<dxs3[i].xi<<"x^"<<dxs3[i].zh;
		}
	}
	return 0;
}

详细

answer.code:7:1: error: 'unordered_map' does not name a type
 unordered_map<int,int> ds1,ds2,ds3;\x0d
 ^
answer.code: In function 'int main()':
answer.code:19:3: error: 'ds1' was not declared in this scope
   ds1[a]+=b;\x0d
   ^
answer.code:25:3: error: 'ds2' was not declared in this scope
   ds2[a]+=b;\x0d
   ^
answer.code:29:13: error: ISO C++ forbids declaration of 'n' with no type [-fpermissive]
  for (auto& n : ds1) {\x0d
             ^
answer.code:29:17: error: range-based 'for' loops are not allowed ...