CodeForces - 805A 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.
Example
Input 19 29 Output 2
Input 3 6 Output 3
题意:给一个区间 l到r,问这里面能被哪个数除净,且这个数能除净的数最多。
分析: 那么如果l==r的话就输出它自己就可以了 当l!=r的时候必定是2能除净的数最多,输出2 AC代码:
#include<stdio.h> int main() { int l,r; scanf("%d%d",&l,&r); if(l==r&&r%2==1) printf("%d\n",r); else printf("2\n"); }