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. MySQL:管理MySQL、事务(三)

    干货: 命令行程序mysql实际上是MySQL客户端,真正的MySQL服务器程序是mysqld,在后台运行. 数据库事务具有ACID特性,用来保证多条SQL的全部执行. 五.MySQL 通过mysql ...

  2. 标准结构篇:2)O型橡胶密封圈

    本章目的:设计出符合行业要求的O型橡胶密封圈,不必再为一而再,再而三的测试漏水而烦恼. 1.前言 O型橡胶密封圈,简称O型圈,是密封圈的一种,也是最有代表性的标准结构件.顾名思义,它的目的在于密封.密 ...

  3. 洛谷 P2053 [SCOI2007]修车(最小费用最大流)

    题解 最小费用最大流 n和m是反着的 首先, \[ ans = \sum{cost[i][j]}*k \] 其中,\(k\)为它在当前技术人员那里,排倒数第\(k\)个修 我们可以对于每个技术人员进行 ...

  4. 关于DES加密强制更新版(4.22)

    数据加密算法(Data Encryption Algorithm,DEA)是一种对称加密算法,很可能是使用最广泛的密钥系统,特别是在保护金融数据的安全中,最初开发的DEA是嵌入硬件中的.通常,自动取款 ...

  5. org.elasticsearch.search.sort.SortBuilder使用

    org.elasticsearch.search.sort.SortBuilder是一个抽象类,有4个子类 org.elasticsearch.search.sort.FieldSortBuilder ...

  6. layui 时间插件laydate ,取消回调

    背景:转型新公司不再是做前端展示H5之类的东西,主要业务是后台数据读取和插件搭建前端页面,接触的第一个老项目是layui制作的,由于业务需求,需要用到时间插件以下为时间插件的一些用法--------- ...

  7. TensorFlow模型转为caffe模型

    最近由于要将训练好的模型移植到硬件上,因此需要将TensorFlow转为caffe模型. caffe模型需要两个文件,一个是定义网络结构的prototxt,一个是存储了参数的caffemodel文件. ...

  8. 1.CSS中的定位机制

    标准文档流(Normal flow) 特点: 从上到下,从左到右,输出文档内容 由块级元素和行级元素组成 块级元素: 从左到右撑满页面,独占一行 触碰到页面边缘时,会自动换行 块级标签: div.ul ...

  9. 怎么用代码弹回 UITableView 中左滑出来的删除按钮

    点击取消,让删除按钮弹回去 [tableView setEditing:NO] 初学 ios 真是大菜鸟,这么简单的一个问题搞了 3 个小时

  10. Git学习系列之 Git 、CVS、SVN的比较

    Git .CVS.SVN比较 项目源代码的版本管理工具中,比较常用的主要有:CVS.SVN.Git 和 Mercurial  (其中,关于SVN,请参见我的博客:SVN学习系列) 目前Google C ...