Codeforces Round #411 A. Fake NP
1 second
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.
The first line contains two integers l and r (2 ≤ l ≤ r ≤ 109).
Print single integer, the integer that appears maximum number of times in the divisors.
If there are multiple answers, print any of them.
19 29
2
3 6
3
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的更多相关文章
- 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 ...
- Codeforces Round #411 (Div. 2)
来自FallDream的博客,未经允许,请勿转载,谢谢. 由于人傻又菜 所以这次又滚去div2了 一堆结论题真的可怕 看见E题不是很有思路 然后就去大力搞F题 T了最后一个点 真的绝望 但 ...
- Codeforces Round #411 (Div. 2) 【ABCDE】
A. Fake NP 题意:给你l,r,让你输出[l,r]里面除1以外的,出现因子数量最多的那个数. 题解:如果l==r输出l,否则都输出2 #include<bits/stdc++.h> ...
- Codeforces Round #411 (Div. 2) A-F
比赛时候切了A-E,fst了A Standings第一页只有三个人挂了A题,而我就是其中之一,真™开心啊蛤蛤蛤 A. Fake NP time limit per test 1 second memo ...
- Codeforces Round #411 div2
A. Fake NP 题意:询问一个区间[L,R]出现次数最多的正整数因子(>1). 一个区间内一个因子P出现次数大概为[R/P]-[(L-1)/P],约等于(R-L+1)/P,P取2时最优.注 ...
- Codeforces Round 411 Div.2 题解
A Fake NP standard input/output s, MB Submit Add to favourites x3673 B -palindrome standard input/ou ...
- Codeforces Round #411 (Div. 1) D. Expected diameter of a tree
题目大意:给出一个森林,每次询问给出u,v,问从u所在连通块中随机选出一个点与v所在连通块中随机选出一个点相连,连出的树的直径期望(不是树输出-1).(n,q<=10^5) 解法:预处理出各连通 ...
- 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 ...
- 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 ...
随机推荐
- php中慎用==
var_dump(' 123fg456'==123);var_dump('some string' == 0);var_dump(123.0 == '123d456');var_dump(0 == & ...
- 认识CSS中盒子模型
前端之HTML,CSS(六) CSS 盒子模型 CSS中的重点,理解盒子模型对于CSS才能有更清晰的认识.网页说简单一点其实就是一块一块的拼接出来的,可以想象成拼图,所有图块拼接在一起就成了一幅图像. ...
- 解决视图状态消息验证代码 (MAC) 错误
https://blog.csdn.net/bingtingabc/article/details/49148745 2015年10月15日 10:05:56 bingtingabc 阅读数:3397 ...
- 透视效果shader(边缘光)
思路:渲染两次. 1.第一次渲染:利用Greater进行深度测试,当目标被遮挡时,用一个边缘光的效果显示. 2.第二次渲染:正常渲染. 边缘光的思路:观察方向和顶点法向量夹角越大,边缘光越明显.边缘光 ...
- Unix_JDK安装及配置
CentOS 下过程 JDK 在 CentOS 和 Ubuntu 下安装过程是一样的,所以这里不再讲 Ubuntu 系统下的安装 JDK 1.8 下载 此时(20170906)最新版本:jdk-8u1 ...
- 简说LINUX 下chmod|chown|chgrp和用法和区别
1.chgrp(改变文件所属用户组) chgrp 用户组 文件名 ###就是这个格了.如果整个目录下的都改,则加-R参数用于递归. 如:chgrp -R user smb.con ...
- python入门练习之如何连接数据库
!/usr/bin/python -- coding: UTF-8 -- author = 'luke' from sqlalchemy import create_engine from sqlal ...
- synchronized的可见性理解
之前的时候看<并发编程的艺术>,书中提到dcl写法的单例模式是有问题的,有可能会导致调用者得到一个创建了一半的对象,从而导致报错.修复办法是将单例对象的引用添加volatile进行修饰,禁 ...
- CentOS6.4 安装Redis
按照下面步骤依次执行1.检查依赖,安装依赖 [root@ecs-3c46 ~]# whereis gcc gcc: /usr/bin/gcc /usr/lib/gcc /usr/libexec/gcc ...
- 游戏反编译工具dnSpy
dnSpy使用的工具下载地址为: https://github.com/cnxy/dnSpy/archive/v4.0.0.zip 或 dnSpy官方下载地址: https://github.com/ ...