当前位置:网站首页>【刷題篇】鹅廠文化衫問題
【刷題篇】鹅廠文化衫問題
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);
}
边栏推荐
- APICloud云调试解决方案
- Cs231n notes (medium) -- applicable to 0 Foundation
- Reduce the cost by 40%! Container practice of redis multi tenant cluster
- Use of set tag in SQL
- 10分钟帮你搞定Zabbix监控平台告警推送到钉钉群
- "21 days proficient in typescript-3" - install and build a typescript development environment md
- Single merchant v4.4 has the same original intention and strength!
- 《21天精通TypeScript-3》-安装搭建TypeScript开发环境.md
- Starkware: to build ZK "universe"
- 后台系统发送验证码功能
猜你喜欢

sql中set标签的使用

服务器的数据库连不上了2003,10060“Unknown error“【服务已起、防火墙已关、端口已开、netlent 端口不通】

ES6深入—async 函数 与 Symbol 类型

有序链表集合求交集 方法 总结

List de duplication and count the number

极坐标扇图使用场景与功能详解

The new version of effect editor is online! 3D rendering, labeling, and animation, this time an editor is enough

Starkware: to build ZK "universe"

Mistakes made when writing unit tests

Background system sending verification code function
随机推荐
抽象类中子类与父类
ES6 drill down - Async functions and symbol types
HiEngine:可媲美本地的云原生内存数据库引擎
漫画:什么是八皇后问题?
How to use FRP intranet penetration +teamviewer to quickly connect to the intranet host at home when mobile office
Single merchant v4.4 has the same original intention and strength!
面对新的挑战,成为更好的自己--进击的技术er
利用GrayLog告警功能实现钉钉群机器人定时工作提醒
List de duplication and count the number
Pits encountered in the use of boolean type in development
移动办公时如何使用frp内网穿透+teamviewer方式快速连入家中内网主机
【深度学习】深度学习如何影响运筹学?
ES6 drill down - ES6 generator function
scratch五彩糖葫芦 电子学会图形化编程scratch等级考试三级真题和答案解析2022年6月
Apiccloud cloud debugging solution
tf.sequence_mask函数讲解案例
The memory of a Zhang
普洛斯数据中心发布DC Brain系统,科技赋能智慧化运营管理
Cartoon: what is distributed transaction?
Win11 prompt: what if the software cannot be downloaded safely? Win11 cannot download software safely