-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathABA12A.cpp
More file actions
42 lines (35 loc) · 884 Bytes
/
ABA12A.cpp
File metadata and controls
42 lines (35 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <cstdio>
#include<cmath>
#define max 100000
using namespace std;
int arr[max]={0};
void sieve(){
int i,j;
for(i=2;i<(max);++i)
{
if(arr[i]>0)continue;
for(j=2*i;j<max;j+=i){
arr[j]++;
}
}
}
long long int maxi=0,m,n,index;
int main() {
int t;
sieve();
//mergeSort(a,0,cntr-1);
scanf("%d",&t);
while(t--)
{
maxi=0;
index=0;
scanf("%lld %lld",&m,&n);
if(n<=3){printf("%lld\n",n);continue;}
for(int i=m;i<=n;i++)
{
if(arr[i]>=maxi){maxi=arr[i];index=i;}
}
printf("%lld\n",index);
}
return 0;
}