B. Vile Grasshoppers

【系统架构设计师】2026年上半年真题论文:论高并发系统的设计与实践 本文围绕高并发系统架构设计展开,重点论述了电商秒杀系统的实战经验。文章采用"痛点-解决方案-效果"的逻辑结构,从缓存设计、异步处理、限流降级、数据库优化等6个维度详细阐述了应对高并发的技术策略。其中,重点介绍了多级缓存体系、基于消息队列的异步处理机制和微服务拆分实践,并辅以实际案例说明如何解决超卖、缓存雪崩等典型问题。全文强调高并发设计需要系统性思维,通过空间换时间、异步换吞吐、横向换能力等原则,最终实现系统吞吐量从500TPS提升至20000TPS的性能突破。 阅读详情
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

The weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape.

The pine's trunk includes several branches, located one above another and numbered from 2 to y. Some of them (more precise, from 2 to p) are occupied by tiny vile grasshoppers which you're at war with. These grasshoppers are known for their awesome jumping skills: the grasshopper at branch x can jump to branches .

Keeping this in mind, you wisely decided to choose such a branch that none of the grasshoppers could interrupt you. At the same time you wanna settle as high as possible since the view from up there is simply breathtaking.

In other words, your goal is to find the highest branch that cannot be reached by any of the grasshoppers or report that it's impossible.

Input

The only line contains two integers p and y (2 ≤ p ≤ y ≤ 109).

Output

Output the number of the highest suitable branch. If there are none, print -1 instead.

Examples
input
Copy
3 6
output
5
input
Copy
3 4
output

-1


给出p,y。

求一个不大于y的,不是2,3,4,p倍数的最大的数。

仔细想一下,不是2,3,4,5,...p的倍数,也就是说是个素数!。

所以我们倒着从y开始,找第一个是素数的数字即可。

#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <iostream>
#include<set>
#include <algorithm>
using namespace std;
int p,y;
bool prime(int x)
{
    for(int i = 2; i*i<=x&&i<=p; i++) {
        if(x%i == 0)
            return false;
    }
    return true;
}
int main()
{


    cin>>p>>y;


        for(int i=y;i>p;i--)
        {
            if(prime(i))
            {
                cout<<i<<endl;
               return 0;
            }
        }
     cout<<"-1"<<endl;
}

Android Framework WMS面试题及参考答案 什么是 WindowManagerService(WMS)?它的作用是什么? WindowManagerService(WMS)是 Android 系统中非常重要的一个系统服务。它运行在系统进程(system_server 进程)中。 从本质上来说,WMS 是 Android 窗口管理系统的核心。它负责管理系统中的所有窗口,包括应用程序窗口、系统窗口(如状态栏、导航栏)等。 它的主要作用有很多。首先是窗口的创建和销毁。当一个应用请求创建一个窗口时,WMS 会协调各个模块完成窗口的创建工 阅读详情

相关推荐

MPU6050 加速度计和陀螺仪传感器与 Arduino 的接口

虽然该模型并不能准确代表现实世界中加速度计传感器的构建方式,但它通常有助于理解为什么加速度计的输出信号通常以 ±g 为单位指定,或者为什么加速度计在静止时在 z 轴上的读数为 1g,或者在不同方向上您可以期望得到什么样的加速度计读数。该模块的核心是低功耗、低成本的 6 轴运动跟踪芯片 MPU6050,它将 3 轴陀螺仪、3 轴加速度计和数字运动处理器 (DMP) 集成到一个 4mm x 4mm 的微型芯片中。小时候,科学博览会上的陀螺仪总是让我们感到惊讶,因为它们以奇怪的方式移动,甚至似乎违背了重力。

sxstj的博客 9948

codeforces 937B Vile Grasshoppers

http://www.elijahqi.win/2018/02/26/codeforces-937b-vile-grasshoppers/ ‎ The weather is fine today and hence it’s high time to climb the nearby pine and enjoy the landscape. The pine’s trunk includes...

Elijahqi 621

材料力学小白必看:纯弯曲正应力计算全解析(附实例演示)

本文详细解析了材料力学中纯弯曲正应力的计算原理与工程应用,通过实例演示帮助初学者掌握关键公式和计算流程。内容涵盖纯弯曲的基本假设、正应力分布规律、截面特性计算,以及现代工具如Excel、ANSYS和Python在应力分析中的应用,特别适合材料力学小白系统学习。

sea99的博客 1247

CF937B Vile Grasshoppers

Vile Grasshoppers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The weather is fine today and hence it's h...

weixin_34189116的博客 188

Akamai移动端Sensor数据采集与BMP风控机制深度解析

本文深度解析了Akamai在移动端风控中的核心机制,重点阐述了Sensor数据如何通过采集陀螺仪、加速度计等硬件信息,结合设备指纹生成连续且符合物理规律的行为轨迹。详细剖析了数据从采集、加密校验到通过BMP风控三重验证(校验位、时间差、数据逻辑)的完整流程,并提供了从模拟优化到自建风控模型的实用应对思路。

quiet的专栏 295

Coze知识库搭建:智能化管理与高效检索实践

知识管理系统是现代企业信息资产管理的核心基础设施,其核心原理是通过结构化存储和智能检索技术实现知识的快速流转。在技术实现上,基于NLP的语义理解引擎和知识图谱构建是关键,能够显著提升检索准确率和知识关联性。以Coze平台为例,其针对中文场景优化的分词算法和多模态处理能力,可有效解决技术文档管理中的术语识别和格式兼容问题。这类系统在开发团队知识沉淀、新员工培训等场景中价值显著,特别是当集成RBAC权限模型和自动化备份策略后,既能保障信息安全,又能实现持续的知识迭代。通过合理配置同义词扩展和权重调整,可使搜索命

weixin_29041195的博客 268

Codeforces Round #467 (Div. 2) B. Vile Grasshoppers

B. Vile GrasshoppersThe weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape.The pine's trunk includes several branches, located one above another and number...

s540239976的博客 518

大语言模型推理机制:Prefill、Decode与KV Cache解析

Transformer架构中的推理过程涉及Prefill、Decode和KV Cache三个关键技术阶段。Prefill阶段负责将输入文本转换为token序列并生成初始隐藏状态,其计算复杂度与输入长度成正比。Decode阶段则以自回归方式逐token生成输出,依赖KV Cache存储历史键值对来避免重复计算。KV Cache作为核心优化机制,通过智能管理对话记忆显著提升推理效率。这些技术在聊天机器人、代码生成等场景中至关重要,特别是KV Cache的内存优化策略直接影响大模型在边缘设备等资源受限环境中的部署

weixin_30664615的博客 447

Codeforces #467 (Div. 2) B. Vile Grasshoppers ( 数学

B. Vile Grasshoppers 题目描述 The weather is fine today and hence it’s high time to climb the nearby pine and enjoy the landscape. The pine’s trunk includes several branches, located one above another...

Yishui_lovely 729

ENVI预处理GF-1号WFV1遥感数据提取NDVI指数

使用ENVI处理GF-1号遥感数据提取NDVI指数

所有专家都曾始于新手 8189

EMB电子机械制动系统和EHB电子液压制动系统控制功能的对比

EMB电子机械制动系统相比EHB液压制动系统具有显著优势:响应速度更快(<100ms)、控制精度更高(±2N·m)、能实现单轮独立控制,支持0.1%级制动力调节。在ABS、ESC等安全功能上表现更优,制动平顺性和NVH性能更好,同时提升能量回收效率15%-20%。特别适合智能驾驶需求,可使AEB等系统响应时间缩短50ms,紧急制动距离减少1米以上。EMB系统完美契合高阶自动驾驶对快速响应和精准控制的要求。

m0_59012156的博客 896

CF937B Vile Grasshoppers题解

这里附上题目链接:CF937B Vile Grasshoppers。 ~~手动分割~~ 题目 思路解析 AC代码 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> int p,y; bool sign=true;//sign=1表示存在符合要求的最大值 int main() { int i,j; //输入数据

ZhuhaoNan134的博客 229

079、镜头阴影校正(LSC)精讲:径向衰减模型、增益矩阵生成与产线标定技巧

《镜头阴影校正(LSC)实战精要》 本文从实际案例出发,深入解析镜头阴影校正的核心技术与产线应用。作者通过一个典型故障案例(0.05mm镜片偏移导致LSC失效)揭示了LSC不仅是数学问题,更是光学-机械-工艺耦合系统。 【关键技术点】 模型优化:提出"径向+切向"双分量模型替代传统cos⁴θ模型,采用5阶多项式拟合径向衰减,1阶线性补偿切向误差 增益矩阵生成:采用自适应网格技术,在边缘区域加密网格,结合中值滤波与高斯平滑消除噪声干扰 产线标定:强调光源均匀性校准(积分球vs平板光源)、坏点预处理、温度补偿等

zzfmlxs的博客 109

B - Vile Grasshoppers

The weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape.The pine's trunk includes several branches, located one above another and numbered from 2 to y. Some...

qq_41694395的博客 326

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

B - Vile Grasshoppers (codeforces)

The weather is fine today and hence it’s high time to climb the nearby pine and enjoy the landscape. The pine’s trunk includes several branches, located one above another and numbered from 2 to y. Som...

qq_43605752的博客 194

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

codeforces 937B Vile Grasshoppers

The weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape.The pine's trunk includes several branches, located one above another and numbered from 2 to y. Some...

Andromeda_Galaxy的博客 587

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

Codeforces 937B Vile Grasshoppers

The weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape.The pine's trunk includes several branches, located one above another and numbered from 2 to...

包子不卖包子 554

CodeForces 937B Vile Grasshoppers【math 超时】

B. Vile Grasshoppers time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output The weather is fine today and hence it’s high time to climb the nearb...

肖火柴的火柴盒 270

937B. Vile Grasshoppers

B. Vile Grasshoppers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The weather is fine today and hence it'

memory_qianxiao的博客 504

电子信息专业四年规划:嵌入式与芯片方向实战路线图

在电子信息类专业的学习中,很多人会陷入“课程杂而不精”的困惑。要解这个问题,需要先理解嵌入式与芯片设计本质上处于同一产业链:嵌入式侧重用芯片做产品,芯片侧重把芯片本身设计出来。无论是LED驱动电路的反馈引脚调节,还是升压电源芯片的拓扑分析,都离不开模拟电路与信号完整性的底层原理。通过掌握寄存器操作、总线协议、状态机与驱动开发,初学者可以逐步搭建从MCU到嵌入式Linux的完整能力栈;而芯片方向则需从Verilog、时序约束到芯片测试与后端流程建立系统认知。这些技术不仅应用于工业网关、智能终端和物联网节点,也

weixin_33906657的博客 223

Vile Grasshoppers CodeForces - 937B

                                 Vile GrasshoppersThe weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape.The pine's trunk includes several branches, locate...

MengX 309

Codeforces 937.B Vile Grasshoppers

B. Vile Grasshoppers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The weather is fine today and hence it's h...

weixin_30381793的博客 129

【Codeforces】937 B. Vile Grasshoppers 数学、细节

http://codeforces.com/contest/937/problem/B 给两个数 p, y; 求 p到y的区间中 不是2到p之间的倍数的最大数 #include &lt;iostream&gt; #include &lt;queue&gt; #include &lt;map&gt; #include &lt;cstring&gt; using namespace std; ...

西瓜不甜的博客 258

Vile Grasshoppers CodeForces - 937B(枚举最小质因数)

The weather is fine today and hence it’s high time to climb the nearby pine and enjoy the landscape. The pine’s trunk includes several branches, located one above another and numbered from 2 to y. Som...

tomjobs的博客 381

Codeforces937 B. Vile Grasshoppers(素数距离性质)

题意: 给定p和y,把[2,p]中每个数都标记,问[p+1,y]中未被标记的最大值 无解则输出-1 数据范围:p,y<=1e9 解法: 显然最大值的质因子都不在[2,p]中,那么用质因子check某个值是否被标记 但是数据范围很大,有1e9,看起来无法全部枚举 但实际上有个结论: <=1e9的两个质数之间的差不超过300,所以从y倒着暴力枚举即可 code: #include<bits/stdc++.h> using namespace std; signed main(){

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz 280
上一篇: poj2823 单调队列,双端队列
下一篇: Code Jam 2008 APAC local onsites Problem C. Millionaire 概率DP
Little_boy_z
博客等级 码龄11年 36粉丝 532原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值