-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPASS486.cpp
More file actions
66 lines (54 loc) · 911 Bytes
/
Copy pathPASS486.cpp
File metadata and controls
66 lines (54 loc) · 911 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cstdio>
#include <map>
using namespace std;
const int MAX_N = 10000001;
int minFactor[MAX_N];
void eratos()
{
for(int i=2; i <= MAX_N; i++)
minFactor[i] = i;
for(int i=2; i*i <= MAX_N; i++)
if(minFactor[i] == i)
for(int j=i*i; j <= MAX_N; j+=i)
if(minFactor[j] == j)
minFactor[j] = i;
}
int main()
{
eratos();
int T;
cin >> T;
while(T--)
{
int N, lo, hi;
cin >> N >> lo >> hi;
int ans = 0;
while(lo <= hi)
{
int nFactor = 1;
int nowFactor = 0;
int nowCnt = 0;
for(int n = lo; n > 1; n /= minFactor[n])
{
if(nowFactor != minFactor[n])
{
nFactor *= nowCnt + 1;
nowFactor = minFactor[n];
nowCnt = 1;
}
else
nowCnt++;
}
nFactor *= nowCnt + 1;
if(nFactor == N)
ans++;
lo++;
}
cout << ans << '\n';
}
return 0;
}