-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPRIME_ODS.cpp
52 lines (45 loc) · 1015 Bytes
/
PRIME_ODS.cpp
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
//
// Created by Atrin Hojjat on 9/18/16.
//
#include <iostream>
#include <map>
#define ll unsigned long long
using namespace std;
int main(){
ll a,b;
cin >> a >> b;
map<ll,int> primes;
{
ll maxn = a-1;
bool *nums = (bool*)malloc((maxn)*sizeof(bool));
memset(nums, true, maxn);
ll i = 0;
while(1){
while(!nums[i])if(++i>=maxn)break;
if(i>=maxn)break;
ll x = i;
while((x+=i+2)<maxn)nums[x] = false;
if((i+2)*(i+2)>maxn+1){
break;
}
i++;
}
for (i = 0; i < maxn; ++i)
{
if(nums[i])
primes[i+2] =0;
}
}
ll ans = 1;
for(auto&p : primes){
ll x = p.first;
while(a>=x){
p.second += (ll)a/x;
p.second -= (ll)b/x;
x*=p.first;
}
ans=(ans*((p.second+1)%1000000007))%1000000007;
}
cout << ans << endl;
return 0;
}