2017-5-5-Train:Codeforces Round #411 (Div. 2)

A. Fake NP(数论水题)

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}

Code:

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int l , r;
 4 int main()
 5 {
 6     int pre = 0 , tail = 0 , sum = 0 , pos = -1;
 7     scanf("%d%d" , &l , &r);
 8     if(l == r)
 9         printf("%d" , l);
10     else
11         printf("2");
12 }

时间: 2024-07-30 05:25:53

2017-5-5-Train:Codeforces Round #411 (Div. 2)的相关文章

Codeforces Round #411 (Div. 2)

A题 分析:傻逼题,两个数的差不大于1输出任意一个,否则输出2 1 #include "iostream" 2 #include "cstdio" 3 #include "cstring" 4 #include "cmath" 5 using namespace std; 6 int main() 7 { 8 long long a,b; 9 while(cin>>a>>b) 10 { 11 if(ab

【推导】Codeforces Round #411 (Div. 1) A. Find Amir

1 2 3 4 5 6 7 4-5-3-6-2-7-1 答案是(n-1)/2 #include<cstdio> using namespace std; int n; int main(){ scanf("%d",&n); printf("%d\n",(n-1)/2); return 0; }

Codeforces Round 411 Div.2 题解

A Fake NP standard input/output 1 s, 256 MB Submit Add to favourites x3673 B 3-palindrome standard input/output 1 s, 256 MB Submit Add to favourites x3760 C Find Amir standard input/output 1 s, 256 MB Submit Add to favourites x3503 D Minimum number o

Codeforces Round #411 (Div. 2)C. Find Amir(想法题)

传送门 Description A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends. There are n schools numerated from 1 to n. One can travel between each pa

Codeforces Round #411 (Div. 2)D. Minimum number of steps(贪心)

传送门 Description We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings "ab" in the string and replace it with the string "bba". If we have no "ab" as a subs

Codeforces Round #279 (Div. 2) ABCD

Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name     A Team Olympiad standard input/output 1 s, 256 MB  x2377 B Queue standard input/output 2 s, 256 MB  x1250 C Hacking Cypher standard input/output 1 s, 256 MB  x740 D Chocolate standard input/

Codeforces Round #257(Div.2) D Jzzhu and Cities --SPFA

题意:n个城市,中间有m条道路(双向),再给出k条铁路,铁路直接从点1到点v,现在要拆掉一些铁路,在保证不影响每个点的最短距离(距离1)不变的情况下,问最多能删除多少条铁路 分析:先求一次最短路,铁路的权值大于该点最短距离的显然可以删去,否则将该条边加入图中,再求最短路,记录每个点的前一个点,然后又枚举铁路,已经删去的就不用处理了,如果铁路权值大于该点最短距离又可以删去,权值相等时,该点的前一个点如果不为1,则这个点可以由其他路到达,这条铁路又可以删去. 由于本题中边比较多,最多可以有8x10^

Codeforces Round #515 (Div. 3)

Codeforces Round #515 (Div. 3) 1 #include<bits/stdc++.h> 2 #include<iostream> 3 #include<cstdio> 4 #include<cstdlib> 5 #include<cstring> 6 #include<cmath> 7 #include<algorithm> 8 #include<queue> 9 #include&l

Codeforces Round #542 (Div. 2)

Codeforces Round #542 (Div. 2) 题目做不下去的我写一写题解 A. Be Positive 水题,考虑正数,负数个数是否\(\geq \lceil \frac{n}{2} \rceil\) B. Two Cakes 给定位置大小为1...n的蛋糕,每种大小共两份,要求两个人从最左边的位置增序各取1..n的蛋糕,求最小步长 两个一起考虑,取到第i块蛋糕,两人的位置状态是确定的,无论是a,b两人怎样分布总是占据了这个位置,有点类似蚂蚁相遇后逆行的想法 所以我们只需min(