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

边栏推荐
- Substance Painter笔记:多显示器且多分辨率显示器时的设置
- Find your own value
- 时空可变形卷积用于压缩视频质量增强(STDF)
- Yyds dry goods inventory # solve the real problem of famous enterprises: cross line
- Wechat applet - Advanced chapter component packaging - Implementation of icon component (I)
- Webrtc audio anti weak network technology (Part 1)
- 缓冲区溢出保护
- IDA pro逆向工具寻找socket server的IP和port
- PAG体验:十分钟完成AE动效部署上线各平台!
- Base64 encoding
猜你喜欢

PyTorch模型训练实战技巧,突破速度瓶颈

Full details of efficientnet model

EfficientNet模型的完整细节

How to enable radius two factor / two factor (2fa) identity authentication for Anheng fortress machine

华为云数据库DDS产品深度赋能

How bad can a programmer be? Nima, they are all talents

Data connection mode in low code platform (Part 2)

2022pagc Golden Sail award | rongyun won the "outstanding product technology service provider of the year"

Novel Slot Detection: A Benchmark for Discovering Unknown Slot Types in the Dialogue System

《微信小程序-进阶篇》组件封装-Icon组件的实现(一)
随机推荐
Novel Slot Detection: A Benchmark for Discovering Unknown Slot Types in the Dialogue System
Novel Slot Detection: A Benchmark for Discovering Unknown Slot Types in the Dialogue System
Base64 encoding
How bad can a programmer be? Nima, they are all talents
Es log error appreciation -- allow delete
PD virtual machine tutorial: how to set the available shortcut keys in the parallelsdesktop virtual machine?
Full details of efficientnet model
拜拜了,大厂!今天我就要去厂里
13 ux/ui/ue best creative inspiration websites in 2022
【服务器数据恢复】某品牌StorageWorks服务器raid数据恢复案例
electron remote 报错
PG基础篇--逻辑结构管理(锁机制--表锁)
JS image to Base64
智汀不用Home Assistant让小米智能家居接入HomeKit
2022年13个UX/UI/UE最佳创意灵感网站
全球首款 RISC-V 笔记本电脑开启预售,专为元宇宙而生!
什么是云原生?这回终于能搞明白了!
Cocoscreator resource encryption and decryption
上半年晋升 P8 成功,还买了别墅!
PLC: automatically correct the data set noise, wash the data set | ICLR 2021 spotlight