Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define fast()(ios_base::sync_with_stdio(false),cin.tie(NULL));
- bool res(int a)
- {
- if(a==1)return false;
- for(int i=2;i<=sqrt(a);i++)
- {
- if(a%i==0)return false;
- }
- return true;
- }
- int main()
- {
- int n;
- scanf("%d",&n);
- while(n--)
- {
- int x,y,i;
- scanf("%d %d",&x,&y);
- for( i=y;i>=x;i--)
- {
- if(res(i))
- {
- printf("%d\n",i);
- break;
- }
- }
- if(i==x-1)printf("-1\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement