Guangdong University freshman season K

Here Insert Picture Description

This problem is not too difficult papered tiger is a little pit
because STL dare to use,
so I really stepped on a pit
subject to the effect
that the highest number of recurring elements within the output range l-r
because I did not expect to be updated and then Hu changed a pass or WA
If WA is not detailed enough where complete without considering
the special circumstances to think
learned a MAP
feeling good with
the Code

#include<bits/stdc++.h>
using namespace std;
const int maxn=120;
long long a[maxn];
long long fun(long long x)
{
	return x*251%996*404*123;
}
int main()
{
	int n,m,swt,l,r;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	while(m--)
	{
		scanf("%d%d%d",&swt,&l,&r);
		int ans=0;
		if(swt==1)
			for(int j=l;j<=r;j++)
				a[j]=fun(a[j]);
		else
		{
			map<long long , int>cnt;
			for(int k=l;k<=r;k++)
				ans=max(ans,++cnt[a[k]]);
			printf("%d\n",ans);
		}
	}
}
Published 54 original articles · won praise 4 · Views 885

Guess you like

Origin blog.csdn.net/weixin_45460987/article/details/103442014