当前位置:网站首页>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 :

边栏推荐
- Full details of efficientnet model
- Attribute keywords serveronly, sqlcolumnnumber, sqlcomputecode, sqlcomputed
- Reading and understanding of eventbus source code
- Promoted to P8 successfully in the first half of the year, and bought a villa!
- 找到自己的价值
- 广州开发区让地理标志产品助力乡村振兴
- Ffmpeg --- image processing
- 华为云数据库DDS产品深度赋能
- Decrypt the three dimensional design of the game
- 15、文本编辑工具VIM使用
猜你喜欢

Zhiting doesn't use home assistant to connect Xiaomi smart home to homekit

Jetson AGX Orin CANFD 使用

Instructions d'utilisation de la trousse de développement du module d'acquisition d'accord du testeur mictr01

Webrtc audio anti weak network technology (Part 1)
![[Yugong series] go teaching course 005 variables in July 2022](/img/66/4265a06a98412bd2c88d8281caf06e.png)
[Yugong series] go teaching course 005 variables in July 2022

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

【愚公系列】2022年7月 Go教学课程 005-变量

防火墙基础之服务器区的防护策略

JSON parsing instance (QT including source code)

"July 2022" Wukong editor update record
随机推荐
[server data recovery] a case of RAID data recovery of a brand StorageWorks server
Differences between cookies and sessions
ES日志报错赏析-maximum shards open
Navigation - are you sure you want to take a look at such an easy-to-use navigation framework?
半小时『直播连麦搭建』动手实战,大学生技术岗位简历加分项get!
Promoted to P8 successfully in the first half of the year, and bought a villa!
Instructions d'utilisation de la trousse de développement du module d'acquisition d'accord du testeur mictr01
Infinite innovation in cloud "vision" | the 2022 Alibaba cloud live summit was officially launched
解析PHP跳出循环的方法以及continue、break、exit的区别介绍
Lidar knowledge drops
13 ux/ui/ue best creative inspiration websites in 2022
Simple use of websocket
8大模块、40个思维模型,打破思维桎梏,满足你工作不同阶段、场景的思维需求,赶紧收藏慢慢学
Summary on adding content of background dynamic template builder usage
Mmkv use and principle
找到自己的价值
Classification of regression tests
Pandora IOT development board learning (HAL Library) - Experiment 12 RTC real-time clock experiment (learning notes)
Andriod --- JetPack :LiveData setValue 和 postValue 的区别
「2022年7月」WuKong编辑器更版记录