Codeforces805 A. Fake NP

xiaoxiao2021-02-27  217

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

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.

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

Definition of a divisor: https://www.mathsisfun.com/definitions/divisor-of-an-integer-.html

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

——————————————————————————————————————

题目的意思是给出l和r求l到r之间每个数因子最多的是几?

思路,分析可知道如果l与r相等那答案就是l,否则2肯定最多

#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <queue> #include <string> #include <vector> using namespace std; #define inf 0x3f3f3f3f #define LL long long int main() { int a,b; scanf("%d%d",&a,&b); if(a==b) printf("%d\n",a); else printf("2\n"); return 0; }

转载请注明原文地址: https://www.6miu.com/read-10835.html

最新回复(0)