当前位置:网站首页>【刷題篇】鹅廠文化衫問題
【刷題篇】鹅廠文化衫問題
2022-07-05 16:31: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);
}
边栏推荐
猜你喜欢

降本40%!Redis多租户集群的容器化实践

Seaborn绘制11个柱状图

CISP-PTE之PHP伪协议总结

公司自用的国产API管理神器

Background system sending verification code function

Pspnet | semantic segmentation and scene analysis

Android 隐私沙盒开发者预览版 3: 隐私安全和个性化体验全都要

abstract关键字和哪些关键字会发生冲突呢

StarkWare:欲构建ZK“宇宙”

服务器的数据库连不上了2003,10060“Unknown error“【服务已起、防火墙已关、端口已开、netlent 端口不通】
随机推荐
Single merchant v4.4 has the same original intention and strength!
Explain in detail the functions and underlying implementation logic of the groups sets statement in SQL
Apiccloud cloud debugging solution
新春限定丨“牛年忘烦”礼包等你来领~
阿掌的怀念
APICloud云调试解决方案
Obj resolves to a set
迁移/home分区
Boost the development of digital economy and consolidate the base of digital talents - the digital talent competition was successfully held in Kunming
给自己打打气
自己要有自己的坚持
Is it safe for Guotai Junan to open an account online
怎样在电脑上设置路由器的WiFi密码
【毕业季】作为一名大二计科在校生,我有话想说
Use of set tag in SQL
What is the difference between EDI license and ICP business license
《21天精通TypeScript-3》-安装搭建TypeScript开发环境.md
CISP-PTE之SQL注入(二次注入的应用)
[深度学习][原创]让yolov6-0.1.0支持yolov5的txt读取数据集模式
The list set is summed up according to a certain attribute of the object, the maximum value, etc