当前位置:网站首页>Niuke real problem programming - day15
Niuke real problem programming - day15
2022-07-07 14:53:00 【weixin_ forty-five million seven hundred and fifty thousand fou】
Compile environment :c++
1、ZJ3 Programming questions 2
describe
One contains only ’a’ and ’b’ Two character string s, The length is n, Each operation can convert a character once ( Put one ’a’ Set to ’b’, Or put one ’b’ Into a ’a’); But there is an upper limit on the number of operations m, Ask within a limited range of operands , What is the length of the substring that can get the largest continuous same character .
Algorithmic thought :
Use the idea of sliding window , First, traverse the string , First, get a subsequence that contains at most (m individual a/m individual b), That is, let the subsequence a perhaps b The number of operations is just critical m when . Then slide the window , Only when satisfied again a Sum of numbers b The number of is greater than m, And one of the characters just exceeds m The condition of , Compare the subsequence length again . After the traversal is completed, the number of operations that meet , The longest subsequence .
The code part implements :

2、 Fishing competition
describe :
ss please cc Go fishing at home , Fish ponds can be divided into n*m Lattice of , Each grid has different probability of catching fish ,cc Always in coordinates (x,y) Grid fishing , and ss Catch a grid randomly every minute . ask t Who of them has a high probability of catching at least one fish in minutes ? How much? ?
Algorithmic thought :
The problem is actually a basic math problem , According to the probability problem ,t The probability of everyone catching fish in minutes can be marked as P event , Yes P=1-(1-P(ss/cc))^t, And for Pcc event , It can be seen that the probability of catching fish per minute is the coordinate element value , and Pss Randomly select the fishing port , Then his probability of catching per minute is the average of the sum of the probabilities of all grids .
The code part implements :

3、 The annual toy game
describe :
At the annual meeting of a company , The organizer arranged a small game to adjust the atmosphere . The rules of the game are as follows :
N Individual participation in the game , Stand in a row to rob the workers M A little doll . In order to increase the fun and difficulty of the game , The rules stipulate , People participating in the game can't grab more than two or more gifts than people on both sides , Otherwise, you will be punished . At the end of the game, the person who has the most dolls will win a grand prize .
Suppose everyone wants to win this prize , Please stand at No K The trick of three positions is to win the game , At most, you can have several dolls ?
Algorithmic thought :
To make the first k The little trick of bit wins the game without violating the rules , Then the number of dolls of small tricks and adjacent participants can only decrease in turn 1 individual . Let the trick get the most dolls first , Then traverse the participants on the left and right side in descending order , Add the number of dolls of everyone in turn . At first, the total number of dolls must be greater than the actual number of dolls , Then let the number of dolls of the trick decrease in turn , When the number of dolls allocated in a cycle does not exceed the actual number of dolls , This is the optimal allocation scheme , Can make small moves under the rules , Get the most dolls . Just print it out , Pay attention to the data processing of abnormal input .
The code part implements :

边栏推荐
- Cocoscreator resource encryption and decryption
- PyTorch模型训练实战技巧,突破速度瓶颈
- Half an hour of hands-on practice of "live broadcast Lianmai construction", college students' resume of technical posts plus points get!
- 数据湖(九):Iceberg特点详述和数据类型
- Apache multiple component vulnerability disclosure (cve-2022-32533/cve-2022-33980/cve-2021-37839)
- 昇腾体验官第五期随手记I
- C# 6.0 语言规范获批
- Because the employee set the password to "123456", amd stolen 450gb data?
- Electronic remote error
- 8大模块、40个思维模型,打破思维桎梏,满足你工作不同阶段、场景的思维需求,赶紧收藏慢慢学
猜你喜欢

Wechat applet - Advanced chapter component packaging - Implementation of icon component (I)

潘多拉 IOT 开发板学习(HAL 库)—— 实验12 RTC实时时钟实验(学习笔记)

用于增强压缩视频质量的可变形卷积密集网络

Pytorch model trains practical skills and breaks through the bottleneck of speed

The world's first risc-v notebook computer is on pre-sale, which is designed for the meta universe!

Apache多个组件漏洞公开(CVE-2022-32533/CVE-2022-33980/CVE-2021-37839)

Infinite innovation in cloud "vision" | the 2022 Alibaba cloud live summit was officially launched

Navigation - are you sure you want to take a look at such an easy-to-use navigation framework?

Pinduoduo lost the lawsuit, and the case of bargain price difference of 0.9% was sentenced; Wechat internal test, the same mobile phone number can register two account functions; 2022 fields Awards an

Five pain points for big companies to open source
随机推荐
Summary on adding content of background dynamic template builder usage
电脑Win7系统桌面图标太大怎么调小
⼀个对象从加载到JVM,再到被GC清除,都经历了什么过程?
Internal sort - insert sort
Attribute keywords serveronly, sqlcolumnnumber, sqlcomputecode, sqlcomputed
Decrypt the three dimensional design of the game
Navigation - are you sure you want to take a look at such an easy-to-use navigation framework?
Because the employee set the password to "123456", amd stolen 450gb data?
Shengteng experience officer Episode 5 notes I
拜拜了,大厂!今天我就要去厂里
JS in the browser Base64, URL, blob mutual conversion
In the field of software engineering, we have been doing scientific research for ten years!
Emqx 5.0 release: open source Internet of things message server with single cluster supporting 100million mqtt connections
Demis hassabis talks about alphafold's future goals
Cocoscreator resource encryption and decryption
Computer win7 system desktop icon is too large, how to turn it down
Classification of regression tests
Differences between cookies and sessions
EfficientNet模型的完整细节
JS image to Base64