跳到正文

题解

CF1543B Customising the Track 题解

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

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟
获赞
1
题目
CF1543B

版本

  1. v1当前

简单分析一下:

它说答案要最小,那么往每个数上放就要平均。

肯定不能正好分完,多余的一个一个分。

然后就是较大的数和较小的数的和。

代码

C++
#include<bits/stdc++.h>
using namespace std;
size_t n,t,a[211111];
int main() {
	cin>>t;
	while(t--) {
		int ans=0;
		cin>>n;
		for(int i=1; i<=n; i++) {
			cin>>a[i];
			ans+=a[i];
		}
		int x=n-ans%n;
		int y=ans%n;
		cout<<x*y<<endl;
	}
	return 0;
}
原文