Advertisement
erfanul007

LA 4340

Mar 16th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef unsigned long long int ull;
  5. typedef long long int ll;
  6. typedef vector<int> vi;
  7. typedef vector<ll> vll;
  8. typedef vector<vi> vvi;
  9. typedef pair<int,int > pii;
  10. typedef vector< pii > vpii;
  11. typedef set<int> sti;
  12.  
  13. #define sc scanf
  14. #define pf printf
  15. #define sci(n) scanf("%d",&n)
  16. #define scl(n) scanf("%lld",&n)
  17. #define scd(n) scanf("%lf",&n)
  18. #define scs(s) scanf("%s",s)
  19. #define pfi(n) printf("%d",n)
  20. #define pfl(n) printf("%lld",n)
  21. #define pff(n) cout<<n
  22. #define line printf("\n")
  23. #define spc printf(" ")
  24. #define loop(i,x,y) for(int i=int(x); i<=int(y); i++)
  25. #define rloop(i,y,x) for(int i=int(y); i>=int(x); i--)
  26. #define cspf(i) printf("Case %d: ", i)
  27. #define pb push_back
  28. #define mp make_pair
  29. #define ff first
  30. #define ss second
  31. #define all(v) v.begin(),v.end()
  32. #define rall(v) v.rbegin(),v.rend()
  33. #define clr(arr,val) memset(arr,val,sizeof arr);
  34. #define read() freopen("input.txt", "r", stdin)
  35. #define write() freopen("output.txt", "w", stdout)
  36. /// Constants
  37. #define eps 1e-9
  38. #define PI acos(-1.0) // 3.1415926535897932
  39. #define MAX 1000007
  40.  
  41. bool chk[10009];
  42. bool factp[10009];
  43. void seive()
  44. {
  45. clr(chk,0);
  46. chk[0]=1;
  47. chk[1]=1;
  48. for(int i=2;i<10005;i++){
  49. if(chk[i]) continue;
  50. for(int j=2;i*j<10005;j++){
  51. chk[i*j]=1;
  52. }
  53. }
  54. }
  55.  
  56. void factcnt()
  57. {
  58. clr(factp,0);
  59. factp[0]=0;
  60. factp[1]=0;
  61. for(int i=2;i<=10002;i++){
  62. int cnt=0;
  63. for(int j=1;j*j<=i;j++){
  64. if(i%j==0){
  65. cnt+=2;
  66. if(i/j==j) cnt--;
  67. }
  68. }
  69. if(!chk[cnt]){
  70. factp[i]=1;
  71. }
  72. else factp[i]=0;
  73. }
  74. }
  75.  
  76. int main(){
  77. read();
  78. write();
  79. //ios_base::sync_with_stdio(false);
  80. //cin.tie(NULL);
  81. seive();
  82. factcnt();
  83. int n;
  84. cin>>n;
  85. while(n--){
  86. int l,h;
  87. cin>>l>>h;
  88. bool flg=0;
  89. for(int i=l;i<=h;i++){
  90. if(factp[i]==1){
  91. if(flg) spc;
  92. flg=1;
  93. cout<<i;
  94. }
  95. }
  96. if(!flg) cout<<-1;
  97. line;
  98. }
  99. return 0;
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement