codeforces 411div2-fake NP
2017-10-23 16:17
1306 查看
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
Output
Input
Output
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}.
#include<cstdio>
#include<iostream>
using namespace std;
int main() {
int l, r;
cin >> l >> r;
if (l == r) cout << l << endl;
else cout << "2" << endl;
return 0;
}
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}.
#include<cstdio>
#include<iostream>
using namespace std;
int main() {
int l, r;
cin >> l >> r;
if (l == r) cout << l << endl;
else cout << "2" << endl;
return 0;
}
相关文章推荐
- codeforces 805A - Fake NP
- 【codeforces 805A】Fake NP
- Fake NP (Codeforces - 805A)
- Educational Codeforces Round 21 Problem F (Codeforces 808F) - 最小割 - 二分答案
- DP训练 Codeforces 816E Karen And SuperMarket [树形DP]
- CodeForces 293E Close Vertices
- CodeForces 446A DZY Loves Sequences (DP+暴力)
- Codeforces 484A - Bits 二进制找1
- Codeforces 144D Missile Silos(SPFA最短路)
- CodeForces - 500C
- Codeforces 872C Maximum splitting【思维】
- codeforces 671B Robin Hood 二分
- CodeForces 732F Tourist Reform
- codeforces 208 E 时间戳 倍增法求LCA
- Codeforces 620E New Year Tree dfs + 线段树(区间查询+区间置数) + 位运算
- Codeforces - 813C The Tag Game
- codeforces 719A 【python】
- Codeforces--140A--New Year Table(思维)
- CodeForces 91B Queue【线段树】
- Codeforces 487B. Strip(求区间最值+线段树上的dp)