当前位置:网站首页>【刷題篇】鹅廠文化衫問題
【刷題篇】鹅廠文化衫問題
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);
}
边栏推荐
- Subclasses and superclasses of abstract classes
- Starkware: to build ZK "universe"
- 新春限定丨“牛年忘烦”礼包等你来领~
- 数据访问 - EntityFramework集成
- Domestic API management artifact used by the company
- 企业级备份软件Veritas NetBackup(NBU) 8.1.1服务端的安装部署
- ES6深入—ES6 Generator 函数
- The new version of effect editor is online! 3D rendering, labeling, and animation, this time an editor is enough
- Relationship between objects and classes
- Find the root of the following equation by chord cutting method, f (x) =x^3-5x^2+16x-80=0
猜你喜欢

Single merchant v4.4 has the same original intention and strength!

數據訪問 - EntityFramework集成

文件操作--I/O

Win11提示无法安全下载软件怎么办?Win11无法安全下载软件
![[deep learning] how does deep learning affect operations research?](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[deep learning] how does deep learning affect operations research?

Parameter type setting error during batch update in project SQL

清晰还原31年前现场,火山引擎超清修复Beyond经典演唱会

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

【刷题篇】有效的数独

ES6深入—async 函数 与 Symbol 类型
随机推荐
Practice independent and controllable 3.0 and truly create the open source business of the Chinese people
《MongoDB入门教程》第04篇 MongoDB客户端
有序链表集合求交集 方法 总结
漫画:什么是八皇后问题?
Research and practice of super-resolution technology in the field of real-time audio and video
Cs231n notes (medium) -- applicable to 0 Foundation
怎样在电脑上设置路由器的WiFi密码
面对新的挑战,成为更好的自己--进击的技术er
Cartoon: what is distributed transaction?
清晰还原31年前现场,火山引擎超清修复Beyond经典演唱会
[graduation season] as a sophomore majoring in planning, I have something to say
OneForAll安装使用
What is the difference between EDI license and ICP business license
RLock锁的使用
给自己打打气
ES6 drill down - Async functions and symbol types
[es6] 模板字符串内添加if判断或添加三元运算符判断
Accès aux données - intégration du cadre d'entité
Single merchant v4.4 has the same original intention and strength!
Win11提示无法安全下载软件怎么办?Win11无法安全下载软件