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

【020】基于51单片机智能路灯系统Proteus仿真与实物设计 阅读详情

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 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.

输入

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

输出

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

样例

inputCopy
3 6
output
5
inputCopy
3 4
output
-1

题意

给两个数 p, y;
求 p到y的区间中 不是2到p之间的倍数的最大数

明显可以知道如果存在这个数
最大的数一定大于等于比y小的那个素数 因为素数与素数之间最大不超过1e3(在1e9的范围内)
那么最大的所用时间大概就是1e3∗sqrt(1e9)1e3∗sqrt(1e9)

AC代码

#include <bits/stdc++.h>
using namespace std;

#define CLR(a,b) memset(a,(b),sizeof(a))
#define LL long long

const int MAXN = 1e3+10;
const double eps = 1e-15;
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;
    return 0;
}
ADS基础教程19 - 电磁仿真(EM)基本概念和实操 一、引言二、基本概念1.EM介绍2.Momentum介绍3.FEM介绍4.Substrate介绍三、创建Layout并进行Momentum仿真1.创建Layout2.添加Microtrip(微带线)3.添加Substrate4.Momentum仿真四、总结EM全称Electromagnetic,即electro(电)magnetic(磁)。ADS为设计和评估现代通信系统产品提供了电磁仿真工具(EM)。EM包括Momentumsimulator(动量仿真器)和FEM。 阅读详情

相关推荐

ANPC三电平拓扑:两种调制方式解析

ANPC结构是基于“I”型NPC结构(下面讲NPC如不特殊说明,均指的是“I”型结构NPC)发展出来的一种改进型。我们在讲NPC结构的时候会谈到他的一个缺点就是损耗分布不均匀,会导致温升不均衡,进而限制模块的功率输出能力。而ANPC结构由于多了两个开关管以及相应的两个中性点换流回路(如下图),可以更加灵活任意的配置开关管可以使损耗没有那么的不均衡,从而能一定程度上提高模块的输出功率。ANPC拓扑结构图以及增加的环流回路。

IOTBOT的博客 9589

Codeforces #467 (Div. 2) C. Save Energy! ( 数学

C. Save Energy! 题目描述 Julia is going to cook a chicken in the kitchen of her dormitory. To save energy, the stove in the kitchen automatically turns off after k minutes after turning on. During coo...

Yishui_lovely 675

OCC入门指南:从零开始掌握Open CASCADE Technology

本文是Open CASCADE Technology(OCC)的入门指南,详细介绍了这款开源C++三维几何建模内核的核心概念与价值。内容涵盖从零开始搭建开发环境、编写第一个显示立方体的程序,到深入理解其几何与拓扑核心、掌握Draw测试工具及Handle内存管理等关键编程范式,旨在帮助开发者快速掌握这一工业级CAD/CAE/CAM应用开发利器。

java5的博客 1279

CodeForces_937C Save Energy!(贪心)

C. Save Energy! time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Julia is going to cook a chicken in the kit...

weixin_30752377的博客 222

合泰单片机HT32之keil5开发环境搭建(一)

1. 前言 这两天在准备合泰杯,但是总是感觉无从下手,因为合泰单片机的资料教程什么的非常少,不像stm32那样。而且听说要用合泰单片机的专用IDE,感觉当场被劝退了。后来经过查找资料,发现合泰单片机也有keil5的支持包,也就是说可以从库函数进行开发,不用从寄存器进行开发,但我找了好久,并没有找到教程,后来实在没办法,打算自己动手搭建环境,经过了大概两天的挣扎后,终于成功地搭建好了环境,也成功地点...

weixin_44713763的博客 8678

Hermes V0.10.0:官方UI几乎无Bug版

如果你还在观望Hermes,现在可能是最好的入局时机。 因为网页端来了,门槛降到了最低。 如果你已经是Hermes用户,升级就对了。 因为0.9.0的更新,值得一试。

weixin_66295112的博客 2059

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

python——模拟砍价

类型:随机数。

m0_62488776的博客 1982

codeforces 936A Save Energy!

http://www.elijahqi.win/2018/02/26/cf936a/ Julia is going to cook a chicken in the kitchen of her dormitory. To save energy, the stove in the kitchen automatically turns off after k minutes after tur...

Elijahqi 835

SAP Workflow审批功能实例详细过程

SAP Workflow审批功能实例详细过程

陈送平的博客 6596

山景BP10_128DBG开发板ADC_Key驱动

最近在学习山景BP10_128DBG开发板,想使用开发板上的按键。看了看原理图和之前用过的按键好像有点不一样。常见的按键都是判断IO口是否被拉低或拉高来判断按键是否被按下。山景BP10_128DBG开发板上的按键是ADC按键,每个按键按下之后ADC的采样值是不同的,通过ADC采样回来的值进而判断哪个按键按下。这种方式核心思想就是用一个ADC通道来节约IO口,对于IO紧张的芯片是一个不错的解决思路。

weixin_56646002的博客 1322

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

规控面试常见问题

规划控制算法常见问题。

每天进步一点点。 995

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

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

Codeforces #467 (Div. 2) B. Vile Grasshoppers 蚂蚱的题目

zj讲了半天,我什么都没听懂,我只是想自己看看我就能明白吧,我?哈哈哈,高数作业还没写,算法课要不要上http://blog.csdn.net/wang2332/article/details/79373271**题意有点重要,其实也就是从2到p这些数字,按倍数往后算吧,直到跳不到,界限 是y那么也就是说有个素数的话,肯定大于素数,因为素数是肯定满足题意的,那个跳不到的点如果由于p的原因并不是素数...

lx233 244

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

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

题目大意: 给出两个整数p,q(2=&lt;p &lt;=q&lt;=10^9),让你在区间(p,q]找出一个数,使这个数不能被区间[2,p]中任何一个数整除,如果满足条件的数有多个,则输出最大的,如果没有满足条件的则输出-1。解析:看到整除,那必定想到了质数,但是数据规模是10^9,所以不太可能打质数表。然而题目只要求最大的,并且目前已知相邻两个素数之间的间隔是246,所以无论求得的数是否为质数...

OttsWang的博客 291

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

Codeforces Round #467 (Div. 2)

A. Olympiad time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The recent All-Berland Olympiad in Informatics f

zP1nG 644

Codeforces Round #467 (Div. 2) 937ABC

第一题: A. Olympiad time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The recent All-Berland Olympiad in Informatics featured n partic...

小博客 390

CentOS 8 EOL后Docker安装失败的根源与替代方案

Docker 是容器化部署的核心基础设施,其安装依赖于底层操作系统的包管理机制与软件源可用性。当系统采用已停止维护的发行版(如 CentOS 8),其默认仓库归档导致 yum-utils 等基础工具缺失、元数据无法下载、dnf install 失败——这本质是软件供应链中断问题,而非配置错误。理解 RHEL 兼容生态、掌握二进制兼容原理,是解决该类问题的关键。技术价值在于规避安全风险、保障长期可维护性;典型应用场景包括生产环境迁移、金融/政务内网部署及 Docker 官方脚本适配。本文聚焦 CentOS 8

weixin_34252090的博客 414

Codeforces Round #467 (Div. 2) B. Vile Grasshoppers[求去掉2-y中所有2-p的数的倍数后剩下的最大值]...

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 ...

weixin_30314631的博客 89

B. Vile Grasshoppers

time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape...

Little_boy_z的博客 281

Codeforces Round #467 (Div. 2)T2题解

原题链接 http://codeforces.com/contest/937/problem/B 题目大意 给定两个数p和y,从2-p所有位置都有障碍,且这些障碍可以占领2-y中所有其的倍数 如p=3,y=6 2,3,一开始被占领 2的倍数4,6,被占领 3的倍数6,被占领 问在2-y中最大的未被占领的数是多少。如果全都被占领了,输出-1 题面 B. Vile Grasshop...

WD_louchenhao的博客 419

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...

包子不卖包子 553

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

Vile Grasshoppers

点击打开链接题目的意思就是从2到p和2到n的倍数的位置已经被占据,你要求的就是在这些没有被占位置上找到一个最大值输出,如果没有就输-1;#include&lt;stdio.h&gt;#include&lt;string&gt;#include&lt;queue&gt;#include&lt;string.h&gt;using namespace std;int a[100000];int v[10...

Mr___jie的博客 371
上一篇: Codeforces #467 (Div. 2) C. Save Energy! ( 数学
下一篇: Codeforces #467 (Div. 2) A. Olympiad
Yishui_Blog
博客等级 码龄10年 96粉丝 524原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值