当前位置:网站首页>【刷题篇】鹅厂文化衫问题
【刷题篇】鹅厂文化衫问题
2022-07-05 15:55:00 【m0_60631323】
一、题目
企鹅厂活动发文化衫,文化衫有很多种,企鹅们都穿文化衫。采访中,企鹅会说还有多少企鹅跟他穿一种文化衫。有些企鹅没被采访到,将这些回答放在answers数组里,返回活动中企鹅的最少数
二、题解
2.1思路



2.2源码
源码:
public static int minPeople(int[] arr){
int x=arr[0];
int c=1;
int ans=0;
for (int i = 0; i < arr.length; i++) {
if(x!=arr[i]){
ans+=((c+x)/(x+1))*(x+1);
x=arr[i];
c=1;
}else {
c++;
}
}
return ans+((c+x)/(x+1))*(x+1);
}
边栏推荐
- How can programmers improve their situation?
- Exception com alibaba. fastjson. JSONException: not match : - =
- Starkware: to build ZK "universe"
- 搜索 正排索引 和 倒排索引 区别
- vant tabbar遮挡内容的解决方式
- 五种常见的咨询公司谈判策略以及如何维护自己的利益
- 一些认知的思考
- Using graylog alarm function to realize the regular work reminder of nail group robots
- Record the pits encountered in the raspberry pie construction environment...
- Apple 已弃用 NavigationView,使用 NavigationStack 和 NavigationSplitView 实现 SwiftUI 导航
猜你喜欢

视觉体验全面升级,豪威集团与英特尔Evo 3.0共同加速PC产业变革

详解SQL中Groupings Sets 语句的功能和底层实现逻辑

Background system sending verification code function

Research and development efficiency measurement index composition and efficiency measurement methodology
![[Netease Yunxin] research and practice of super-resolution technology in the field of real-time audio and video](/img/69/3aedcdafb2b4e83087dc1ce593dc38.png)
[Netease Yunxin] research and practice of super-resolution technology in the field of real-time audio and video

Reduce the cost by 40%! Container practice of redis multi tenant cluster

Use of RLOCK lock

Flet教程之 12 Stack 重叠组建图文混合 基础入门(教程含源码)
英特尔第13代Raptor Lake处理器信息曝光:更多核心 更大缓存

Oneforall installation and use
随机推荐
Win11如何给应用换图标?Win11给应用换图标的方法
Intel 13th generation Raptor Lake processor information exposure: more cores, larger cache
The memory of a Zhang
Desci: is decentralized science the new trend of Web3.0?
Cartoon: what is the eight queens problem?
Today's sleep quality record 79 points
新春限定丨“牛年忘烦”礼包等你来领~
Background system sending verification code function
[vulnerability warning] cve-2022-26134 conflict Remote Code Execution Vulnerability POC verification and repair process
漫画:什么是分布式事务?
漫画:什么是八皇后问题?
漫画:什么是蓝绿部署?
Record the pits encountered in the raspberry pie construction environment...
list使用Stream流进行根据元素某属性数量相加
极坐标扇图使用场景与功能详解
Quelques réflexions cognitives
How to use FRP intranet penetration +teamviewer to quickly connect to the intranet host at home when mobile office
Win11提示无法安全下载软件怎么办?Win11无法安全下载软件
Query the latest record in SQL
The new version of effect editor is online! 3D rendering, labeling, and animation, this time an editor is enough