当前位置:网站首页>【刷題篇】鹅廠文化衫問題
【刷題篇】鹅廠文化衫問題
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);
}
边栏推荐
- 清晰还原31年前现场,火山引擎超清修复Beyond经典演唱会
- list使用Stream流进行根据元素某属性数量相加
- HiEngine:可媲美本地的云原生内存数据库引擎
- Cartoon: what is the eight queens problem?
- Five common negotiation strategies of consulting companies and how to safeguard their own interests
- Spring Festival Limited "forget trouble in the year of the ox" gift bag waiting for you to pick it up~
- 數據訪問 - EntityFramework集成
- The difference between searching forward index and inverted index
- ES6 drill down - ES6 generator function
- 数据访问 - EntityFramework集成
猜你喜欢
抽象类中子类与父类
公司自用的国产API管理神器
清晰还原31年前现场,火山引擎超清修复Beyond经典演唱会
Pits encountered in the use of boolean type in development
Flet教程之 09 NavigationRail 基础入门(教程含源码)
The visual experience has been comprehensively upgraded, and Howell group and Intel Evo 3.0 have jointly accelerated the reform of the PC industry
新春限定丨“牛年忘烦”礼包等你来领~
2020-2022两周年创作纪念日
How to set the WiFi password of the router on the computer
ES6深入—async 函数 与 Symbol 类型
随机推荐
单商户 V4.4,初心未变,实力依旧!
Flet教程之 12 Stack 重叠组建图文混合 基础入门(教程含源码)
yarn 常用命令
漫画:什么是分布式事务?
list使用Stream流进行根据元素某属性数量相加
今日睡眠质量记录79分
Cs231n notes (top) - applicable to 0 Foundation
自己要有自己的坚持
RLock锁的使用
【毕业季】作为一名大二计科在校生,我有话想说
Practice independent and controllable 3.0 and truly create the open source business of the Chinese people
英特尔第13代Raptor Lake处理器信息曝光:更多核心 更大缓存
Cheer yourself up
OneForAll安装使用
漫画:什么是八皇后问题?
[vulnerability warning] cve-2022-26134 conflict Remote Code Execution Vulnerability POC verification and repair process
搜索 正排索引 和 倒排索引 区别
践行自主可控3.0,真正开创中国人自己的开源事业
The visual experience has been comprehensively upgraded, and Howell group and Intel Evo 3.0 have jointly accelerated the reform of the PC industry
Mongodb getting started Tutorial Part 04 mongodb client