Pinkie Pie Eats Patty-cakes CodeForces - 1393C rat1200

Pinkie Pie has bought a bag of patty-cakes with different fillings! But it appeared that not all patty-cakes differ from one another with filling. In other words, the bag contains some patty-cakes with the same filling.

Pinkie Pie eats the patty-cakes one-by-one. She likes having fun so she decided not to simply eat the patty-cakes but to try not to eat the patty-cakes with the same filling way too often. To achieve this she wants the minimum distance between the eaten with the same filling to be the largest possible. Herein Pinkie Pie called the distance between two patty-cakes the number of eaten patty-cakes strictly between them.

Pinkie Pie can eat the patty-cakes in any order. She is impatient about eating all the patty-cakes up so she asks you to help her to count the greatest minimum distance between the eaten patty-cakes with the same filling amongst all possible orders of eating!

Pinkie Pie is going to buy more bags of patty-cakes so she asks you to solve this problem for several bags!

Input
The first line contains a single integer T (1≤T≤100): the number of bags for which you need to solve the problem.

The first line of each bag description contains a single integer n (2≤n≤105): the number of patty-cakes in it. The second line of the bag description contains n integers a1,a2,…,an (1≤ai≤n): the information of patty-cakes’ fillings: same fillings are defined as same integers, different fillings are defined as different integers. It is guaranteed that each bag contains at least two patty-cakes with the same filling.

It is guaranteed that the sum of n over all bags does not exceed 105.

Output
For each bag print in separate line one single integer: the largest minimum distance between the eaten patty-cakes with the same filling amongst all possible orders of eating for that bag.

Example
Input
4
7
1 7 1 6 4 4 6
8
1 1 4 6 4 6 4 7
3
3 3 3
6
2 5 2 3 1 4
Output
3
2
0
4
Note
For the first bag Pinkie Pie can eat the patty-cakes in the following order (by fillings): 1, 6, 4, 7, 1, 6, 4 (in this way, the minimum distance is equal to 3).

For the second bag Pinkie Pie can eat the patty-cakes in the following order (by fillings): 1, 4, 6, 7, 4, 1, 6, 4 (in this way, the minimum distance is equal to 2).
寻找数值最大的数出现的个数,先把最多的数字排列好再去插入剩下的数字

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<cstdio>
#include<vector>
#include<set>
#include<cstring>
#include<cstdlib>
#include<time.h>
#include<stack>
using namespace std;
#define ll long long
const int inf=0x3f3f3f;
const int maxn=2e7;
const int mod=1e9+7;
const int base=26;	
int a[maxn];
int main()
{
	int t;
	cin>>t;
	while(t--){
		int n;
		memset(a,0,sizeof(a));//计数
		cin>>n;
		int mx=-1,sum=1;
		for(int i=0;i<n;i++){
			int m;
			cin>>m;
			a[m]++;
			if(mx==a[m]) sum++;
			if(mx<a[m]){
				mx=max(mx,a[m]);
				sum=1;
			}		
		}
		cout<<(n-sum)/(mx-1)-1<<endl;
	}
    system("pause");
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是利用MediaPipe进行手掌关键点预测时,根据手腕、食指根部和小指根部的坐标确定左右手的Python代码: ```python import cv2 import mediapipe as mp mp_drawing = mp.solutions.drawing_utils mp_hands = mp.solutions.hands # 初始化MediaPipe Hands hands = mp_hands.Hands( static_image_mode=True, max_num_hands=1, min_detection_confidence=0.5) # 读取图片 image = cv2.imread('hand.jpg') image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) # 处理图片,获取手掌关键点 results = hands.process(image) if not results.multi_hand_landmarks: print('No hands found.') exit() # 获取手掌关键点的坐标 landmarks = results.multi_hand_landmarks[0] landmark_coords = [] for landmark in landmarks.landmark: x = landmark.x * image.shape[1] y = landmark.y * image.shape[0] landmark_coords.append((x, y)) # 判断左右手 wrist = landmark_coords[0] index_finger_base = landmark_coords[5] pinkie_finger_base = landmark_coords[17] if wrist[0] < index_finger_base[0] and wrist[0] < pinkie_finger_base[0]: print('Left hand') else: print('Right hand') # 可视化结果 image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR) mp_drawing.draw_landmarks( image, landmarks, mp_hands.HAND_CONNECTIONS) cv2.imshow('MediaPipe Hands', image) cv2.waitKey(0) # 释放资源 hands.close() cv2.destroyAllWindows() ``` 这段代码首先初始化了MediaPipe Hands,并读取了一张手掌图片。然后,它处理图片,获取手掌关键点的坐标。接着,它根据手腕、食指根部和小指根部的坐标判断左右手,并输出结果。最后,它可视化了结果,将手掌关键点和连接线绘制在图片上,并显示图片。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值