-
Notifications
You must be signed in to change notification settings - Fork 2
/
1302.txt
58 lines (57 loc) · 1.23 KB
/
1302.txt
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
Author: Kanan Asgarli
*/
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <ostream>
#include <fstream>
#include <cstring>
#include <string>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <memory>
#define pi acos(-1.0)
#define MAX 1000000
using namespace std;
long long p[MAX + 1], l, r, m[MAX], k, P = 1, num, tests;
void primes(){
for(int i = 2; i <= (int)sqrt(MAX); i++)
if( p[i] == 0 )
for(int j = i*i; j <= MAX; j += i )
p[j] = 1;
}
int main()
{
primes();
for(int i = 1; i <= 12; i++)
P = P * 10;
for(int i = 2; i <= MAX; i++)
if( p[i] == 0 ){
num = i;
for(int j = 1; j <= 64; j++){
num = num * i;
if( num < P )
m[++k] = num;
else
break;
}
}
cin>>tests;
while( tests-- ){
cin>>l>>r;
int ans = 0;
for(int i = 1; i <= k; i++)
if( m[i] >= l && m[i] <= r )
ans++;
cout<<ans<<endl;
}
return 0;
}