当前位置:网站首页>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 :
边栏推荐
- Reading and understanding of eventbus source code
- How to enable radius two factor / two factor (2fa) identity authentication for Anheng fortress machine
- Because the employee set the password to "123456", amd stolen 450gb data?
- Lidar Knowledge Drop
- Nllb-200: meta open source new model, which can translate 200 languages
- Summary on adding content of background dynamic template builder usage
- Bill Gates posted his resume 48 years ago: "it's not as good-looking as yours."
- Five pain points for big companies to open source
- 《微信小程序-进阶篇》组件封装-Icon组件的实现(一)
- 广州开发区让地理标志产品助力乡村振兴
猜你喜欢
Huawei cloud database DDS products are deeply enabled
时空可变形卷积用于压缩视频质量增强(STDF)
Substance painter notes: settings for multi display and multi-resolution displays
Data Lake (IX): Iceberg features and data types
PyTorch模型训练实战技巧,突破速度瓶颈
The world's first risc-v notebook computer is on pre-sale, which is designed for the meta universe!
Beginner JSP
Protection strategy of server area based on Firewall
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
Internal sort - insert sort
随机推荐
[today in history] July 7: release of C; Chrome OS came out; "Legend of swordsman" issued
15、文本编辑工具VIM使用
Cocoscreator operates spine for animation fusion
Stm32cubemx, 68 sets of components, following 10 open source protocols
云上“视界” 创新无限 | 2022阿里云直播峰会正式上线
激光雷達lidar知識點滴
Apache multiple component vulnerability disclosure (cve-2022-32533/cve-2022-33980/cve-2021-37839)
MicTR01 Tester 振弦采集模塊開發套件使用說明
KITTI数据集简介与使用
Cocoscreator resource encryption and decryption
Protection strategy of server area based on Firewall
What is the process of ⼀ objects from loading into JVM to being cleared by GC?
广州开发区让地理标志产品助力乡村振兴
今日睡眠质量记录78分
"July 2022" Wukong editor update record
昇腾体验官第五期随手记I
#yyds干货盘点# 解决名企真题:交叉线
EMQX 5.0 发布:单集群支持 1 亿 MQTT 连接的开源物联网消息服务器
Electronic remote error
Es log error appreciation -maximum shards open