跳到正文

题解

可爱数字题解

zcygod约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟

版本

仅有当前版本

可爱数字题解

代码

先上全代码

C++
#include<iostream>
#define int long long
using namespace std;
signed main() {
  //一定开longlong,要不然卡最后一个点——痛失40分
	int t,n;
	cin >>t ;
	for(int i=0;i<t;i++){
		n=0;
		int a[200001]={0},count[200001]={0};//数据范围是2*10^5
		cin >> n;
		for(int j=0;j<n;j++){
			cin >> a[j];
			count[a[j]]++;
		}
		int max=0;
		for(int j=0;j<n;j++){
			if(max<count[a[j]]*a[j])
			max=count[a[j]]*a[j];
		}
		cout<< max <<endl;
	}
}

思路

简单的模拟,设置一个桶,存储各个数字的可爱值(一定要开够!!开不够的话(像我)痛失40)及时输出即可,不需要最后再输出

总结

非常简单的模拟和桶题

原文