Pagini recente » Cod sursa (job #2400598) | Cod sursa (job #2693639) | Cod sursa (job #3159144) | Cod sursa (job #595425) | Cod sursa (job #850444)
Cod sursa(job #850444)
#include <cstdio>
#include <bitset>
#define XMax 1000005
#define LL long long
using namespace std;
bitset <XMax> V, Not;
int F[XMax], A, B;
LL S;
void Eratosthenes ()
{
for (int i=2; i<XMax; ++i)
{
if (!F[i])
{
F[i]=1;
for (int j=i+i; j<XMax; j+=i)
{
++F[j];
}
if (1LL*i*i>=XMax) continue;
for (int j=i*i; j<XMax; j+=(i*i))
{
Not[j]=1;
}
}
}
}
void Pinex ()
{
S=1LL*A*B;
for (int X=2; X<XMax; ++X)
{
if (Not[X]) continue;
int Sign=-1;
if (F[X]%2) Sign=1;
S-=(1LL*Sign*(A/X)*(B/X));
}
}
void Solve ()
{
Eratosthenes ();
Pinex ();
}
void Read ()
{
freopen ("mins.in", "r", stdin);
scanf ("%lld %lld", &A, &B);
--A, --B;
}
void Print ()
{
freopen ("mins.out", "w", stdout);
printf ("%lld\n", S);
}
int main()
{
Read ();
Solve ();
Print ();
return 0;
}