A. Fake NP
time limit per test  

1 second

memory limit per test  

256 megabytes

 

Tavak and Seyyed are good friends. Seyyed is very funny and he told Tavak to solve the following problem instead of longest-path.

You are given l and r. For all integers from l to r, inclusive, we wrote down all of their integer divisors except 1. Find the integer that we wrote down the maximum number of times.

Solve the problem to show that it's not a NP problem.

Input

The first line contains two integers l and r (2 ≤ l ≤ r ≤ 109).

Output

Print single integer, the integer that appears maximum number of times in the divisors.

If there are multiple answers, print any of them.

 
input
19 29
output
2
input
3 6
output
3
Note:

The first example: from 19 to 29 these numbers are divisible by 2: {20, 22, 24, 26, 28}.

The second example: from 3 to 6 these numbers are divisible by 3: {3, 6}.

题目大意:

     给定一个范围,输出一个整数x,(使得这个范围内能整除x的整数个数最多)

解题思路:

     刚开始写的时候没想辣么多,处理超级复杂,之后仔细想想其实只有两种情况

     1、当l和r相同时任意输出一个。  2、当l和r不同时输出2(所有的偶数都能被2整除)

AC代码:

 #include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
using namespace std; int main ()
{
int l,r;
while (~scanf("%d %d",&l,&r))
{
if (l == r)
printf("%d\n",l);
else
printf("2\n");
}
return ;
}

Codeforces Round #411 A. Fake NP的更多相关文章

  1. Codeforces Round #411 (Div. 2)(A,B,C,D 四水题)

    A. Fake NP time limit per test:1 second memory limit per test:256 megabytes input:standard input out ...

  2. Codeforces Round #411 (Div. 2)

    来自FallDream的博客,未经允许,请勿转载,谢谢. 由于人傻又菜 所以这次又滚去div2了  一堆结论题真的可怕 看见E题不是很有思路   然后就去大力搞F题  T了最后一个点 真的绝望   但 ...

  3. Codeforces Round #411 (Div. 2) 【ABCDE】

    A. Fake NP 题意:给你l,r,让你输出[l,r]里面除1以外的,出现因子数量最多的那个数. 题解:如果l==r输出l,否则都输出2 #include<bits/stdc++.h> ...

  4. Codeforces Round #411 (Div. 2) A-F

    比赛时候切了A-E,fst了A Standings第一页只有三个人挂了A题,而我就是其中之一,真™开心啊蛤蛤蛤 A. Fake NP time limit per test 1 second memo ...

  5. Codeforces Round #411 div2

    A. Fake NP 题意:询问一个区间[L,R]出现次数最多的正整数因子(>1). 一个区间内一个因子P出现次数大概为[R/P]-[(L-1)/P],约等于(R-L+1)/P,P取2时最优.注 ...

  6. Codeforces Round 411 Div.2 题解

    A Fake NP standard input/output s, MB Submit Add to favourites x3673 B -palindrome standard input/ou ...

  7. Codeforces Round #411 (Div. 1) D. Expected diameter of a tree

    题目大意:给出一个森林,每次询问给出u,v,问从u所在连通块中随机选出一个点与v所在连通块中随机选出一个点相连,连出的树的直径期望(不是树输出-1).(n,q<=10^5) 解法:预处理出各连通 ...

  8. Codeforces Round #411 div 2 D. Minimum number of steps

    D. Minimum number of steps time limit per test 1 second memory limit per test 256 megabytes input st ...

  9. Codeforces Round #411 (Div. 2) C. Find Amir

    C. Find Amir time limit per test   1 second memory limit per test   256 megabytes   A few years ago ...

随机推荐

  1. PHP错误与异常处理

    https://www.cnblogs.com/zyf-zhaoyafei/p/6928149.html 请一定要注意,没有特殊说明:本例 PHP Version < 7 说起PHP异常处理,大 ...

  2. apache的应用(发布目录,黑白名单,虚拟主机,PHP-cgi支持,正向代理,https加密,)

    [root@apache1 ~]# yum install httpd -y [root@apache1 ~]# cd /var/www/html/   进入默认发布目录 [root@apache1 ...

  3. Ntp客户端

    function parseMsg (buffer) { if (buffer.length !== 48) return; const pkt = {}, now = new Date().getT ...

  4. 更改kindeditor编辑器,改用支持h5的video标签替换原有embed标签

    kindeditor是一款不错的可视化编辑器,不过最近几年似乎没在更新,现在h5趋于主流,正好有个业务需要编辑器支持mp4视频的播放,考虑到现在h5中的video标签的强大,于是决定将原来系统中的em ...

  5. Eclipse for J2EE+tomcat配置上的一些问题

    之前下载了一个eclipse基础版本,学习之前没有什么感觉不方便的地方,方式学习到web编程时,就出现问题了,因为不支持创建web项目. 于是下载了一个Eclipse for J2EE版本的工具,但是 ...

  6. Jquery jqXHR对象的属性和方法

    在 jQuery 1.4 之前(包括1.4),$.ajax() 方法返回的是浏览器原生的 XMLHttpRequest 对象. 从 jQuery 1.5 开始,$.ajax() 方法返回 jQuery ...

  7. ActiveMQ_Linux安装

    首先ActiveMQ查看你需要的版本 官网:http://activemq.apache.org/ 我这里选择的是:apache-activemq-5.14.0-bin.tar.gz 然后在linux ...

  8. 实体类的状态与Hibernate缓存

    一.Hibernate中实体类的三种状态 1.瞬时态 该状态下实体类对象的id属性没有值,该对象和session也没有关系. 实例: UserEntity user = new UserEntity( ...

  9. 自定义控件如何给特殊类型的属性添加默认值 z(转)

    自定义控件如何给特殊类型的属性添加默认值 z 定义控件如何给特殊类型的属性添加默认值了,附自定义GroupBox一枚 标题有点那啥,但确实能表达我掌握此法后的心情. 写自定义控件时往往会有一个需求,就 ...

  10. 使用idea开发工具,nginx服务部署Extjs6,SpringBoot项目到服务器

    编译ExtJs文件 1.输入命令 2.开始编译 3.找到编译后的文件 E:\idea_project\BaiSheng_Model\fin-ui\build\production\Admin 4.将文 ...