fork(1) download
  1. //It's all about what U BELIEVE
  2. #include<map>
  3. #include<set>
  4. #include<stack>
  5. #include<queue>
  6. #include<deque>
  7. #include<cmath>
  8. #include<bitset>
  9. #include<vector>
  10. #include<cstring>
  11. #include<stdio.h>
  12. #include<iostream>
  13. #include<algorithm>
  14. #define endl '\n'
  15. #define PI acos(-1)
  16. #define INF ~(1<<31)
  17. #define pb push_back
  18. #define pob pop_back
  19. #define wtm while(t--)
  20. #define wnm while(n--)
  21. #define MOD 1000000007
  22. #define lsone(Z) (Z&-Z)
  23. #define gcu getchar_unlocked
  24. #define allof(Z) Z.begin(),Z.end()
  25. #define rallof(Z) Z.rbegin(),Z.rend()
  26. #define mset(z,v) memset(z,v,sizeof(z))
  27. #define lne if(line)puts("");else line =1
  28. #define fo(s,y,z) for(int y=s ; y<(int)z ; y++)
  29. #define readf freopen("/home/ebram96/Desktop/in" , "r" , stdin);
  30. #define writef freopen("/home/ebram96/Desktop/out" , "w" , stdout);
  31. using namespace std;
  32. typedef unsigned long long ull;
  33. typedef pair<ull,ull> pairull;
  34. typedef pair<int,int> pairii;
  35. typedef vector<string> vstr;
  36. typedef deque<int> dqint;
  37. typedef set<ull> setull;
  38. typedef unsigned int ui;
  39. typedef queue<int> qint;
  40. typedef vector<int> vi;
  41. typedef set<int> seti;
  42. typedef long long ll;
  43. //int dx[]={-1,0,1, 0,-1,1, 1,-1};
  44. //int dy[]={ 0,1,0,-1, 1,1,-1,-1};
  45. bool prime(int n)
  46. {
  47. int rt = sqrt(n);
  48. for(int i = 3 ; i <= rt ; i+=2)if(n%i==0)
  49. return 0;
  50. return 1;
  51. }
  52. int main()
  53. {
  54. //readf
  55. ll p , y;
  56. cin>>p>>y;
  57. y-=(y%2==0);
  58. while(y > p)
  59. {
  60. if(prime(y))
  61. {
  62. printf("%lld",y);
  63. return 0;
  64. }
  65. y-=2;
  66. }
  67. puts("-1");
  68. }
Success #stdin #stdout 0s 4448KB
stdin
3 6
stdout
5