当前位置:网站首页>[brush title] goose factory shirt problem
[brush title] goose factory shirt problem
2022-07-05 16:31:00 【m0_ sixty million six hundred and thirty-one thousand three hun】
One 、 subject
Penguin factory activity hair shirt , There are many kinds of t-shirts , Penguins wear T-shirts . In an interview with , Penguins will say how many more penguins wear a T-shirt with him . Some penguins were not interviewed , Put these answers in answers In the array , Return the minimum number of penguins in the activity
Two 、 Answer key
2.1 Ideas
2.2 Source code
Source code :
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);
}
边栏推荐
- 《21天精通TypeScript-3》-安装搭建TypeScript开发环境.md
- Enter a command with the keyboard
- Parameter type setting error during batch update in project SQL
- The database of the server is not connected to 200310060 "unknown error" [the service is up, the firewall is off, the port is on, and the netlent port is not connected]
- JSON转MAP前后数据校验 -- 自定义UDF
- Explain in detail the functions and underlying implementation logic of the groups sets statement in SQL
- 數據訪問 - EntityFramework集成
- 服务器的数据库连不上了2003,10060“Unknown error“【服务已起、防火墙已关、端口已开、netlent 端口不通】
- Which keywords will conflict with the abstract keyword
- 【刷题篇】有效的数独
猜你喜欢
后台系统发送验证码功能
Mistakes made when writing unit tests
list去重并统计个数
Reduce the cost by 40%! Container practice of redis multi tenant cluster
ES6 drill down - ES6 generator function
【刷题篇】有效的数独
CISP-PTE之PHP伪协议总结
scratch五彩糖葫芦 电子学会图形化编程scratch等级考试三级真题和答案解析2022年6月
服务器的数据库连不上了2003,10060“Unknown error“【服务已起、防火墙已关、端口已开、netlent 端口不通】
抽象类和接口的区别
随机推荐
2020-2022 two-year anniversary of creation
ES6 deep - ES6 class class
[js] skill simplification if empty judgment
Enter a command with the keyboard
抽象类和接口的区别
漫画:什么是蓝绿部署?
Cartoon: what is the eight queens problem?
Cartoon: what is distributed transaction?
【刷题篇】鹅厂文化衫问题
Record a 'very strange' troubleshooting process of cloud security group rules
【漏洞预警】CVE-2022-26134 Confluence 远程代码执行漏洞POC验证与修复过程
Mongodb getting started Tutorial Part 04 mongodb client
Parameter type setting error during batch update in project SQL
Exception com alibaba. fastjson. JSONException: not match : - =
二叉树相关OJ题
Pits encountered in the use of boolean type in development
The difference between searching forward index and inverted index
10分钟帮你搞定Zabbix监控平台告警推送到钉钉群
Mistakes made when writing unit tests
"21 days proficient in typescript-3" - install and build a typescript development environment md