Pagini recente » Cod sursa (job #1703813) | Cod sursa (job #839899) | Cod sursa (job #2958827) | Cod sursa (job #1647298) | Cod sursa (job #547287)
Cod sursa(job #547287)
#include<cstdio>
#include<cstring>
#define ll long long
const int N=1000005;
int c,d,nrp,pr[N];
ll s;
inline void sch(int &a,int &b)
{
int aux=a;
a=b;
b=aux;
}
void read()
{
freopen("mins.in","r",stdin);
freopen("mins.out","w",stdout);
scanf("%d%d",&c,&d);
if(c>d)
sch(c,d);
c--;
d--;
}
void ciur()
{
bool f[N];
memset(f,false,N);
for(int i=2;i<N;i++)
if(!f[i])
{
pr[++nrp]=i;
if((ll)i*i<N)
for(int j=i*i;j<N;j+=i)
f[j]=true;
}
}
void back(int poz,int prod,int nrf)
{
if(poz>nrp || (ll)c<(ll)prod*pr[poz])
{
if(nrf%2==0)
s+=(ll)(d/prod)*(c/prod);
else
s-=(ll)(d/prod)*(c/prod);
return;
}
back(poz+1,prod*pr[poz],nrf+1);
back(poz+1,prod,nrf);
}
void solve()
{
back(1,1,0);
printf("%lld",s);
}
int main()
{
read();
ciur();
solve();
return 0;
}