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

边栏推荐
- 【愚公系列】2022年7月 Go教学课程 005-变量
- 暑期安全很重要!应急安全教育走进幼儿园
- PAG体验:十分钟完成AE动效部署上线各平台!
- Lidar Knowledge Drop
- ⼀个对象从加载到JVM,再到被GC清除,都经历了什么过程?
- 安恒堡垒机如何启用Radius双因素/双因子(2FA)身份认证
- How does the database perform dynamic custom sorting?
- EMQX 5.0 发布:单集群支持 1 亿 MQTT 连接的开源物联网消息服务器
- Simple steps for modifying IP of sigang electronic scale
- KITTI数据集简介与使用
猜你喜欢

Stm32cubemx, 68 sets of components, following 10 open source protocols

Jetson AGX Orin CANFD 使用

Spatiotemporal deformable convolution for compressed video quality enhancement (STDF)

CTFshow,信息搜集:web1

What is the process of ⼀ objects from loading into JVM to being cleared by GC?

全球首款 RISC-V 笔记本电脑开启预售,专为元宇宙而生!

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

KITTI数据集简介与使用

CPU与chiplet技术杂谈

AWS learning notes (III)
随机推荐
Pandora IOT development board learning (HAL Library) - Experiment 12 RTC real-time clock experiment (learning notes)
Deformable convolutional dense network for enhancing compressed video quality
Spatiotemporal deformable convolution for compressed video quality enhancement (STDF)
Half an hour of hands-on practice of "live broadcast Lianmai construction", college students' resume of technical posts plus points get!
Navigation — 这么好用的导航框架你确定不来看看?
STM32CubeMX,68套组件,遵循10条开源协议
Novel Slot Detection: A Benchmark for Discovering Unknown Slot Types in the Dialogue System
Substance Painter笔记:多显示器且多分辨率显示器时的设置
The world's first risc-v notebook computer is on pre-sale, which is designed for the meta universe!
Because the employee set the password to "123456", amd stolen 450gb data?
Applet directory structure
Lidar knowledge drops
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
Wechat applet - Advanced chapter component packaging - Implementation of icon component (I)
EfficientNet模型的完整细节
拼多多败诉,砍价始终差0.9%一案宣判;微信内测同一手机号可注册两个账号功能;2022年度菲尔兹奖公布|极客头条...
Promoted to P8 successfully in the first half of the year, and bought a villa!
全球首款 RISC-V 笔记本电脑开启预售,专为元宇宙而生!
解析PHP跳出循环的方法以及continue、break、exit的区别介绍
大厂做开源的五大痛点