Cod sursa(job #2149193)

Utilizator topala.andreiTopala Andrei topala.andrei Data 2 martie 2018 13:20:11
Problema Mins Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.83 kb
#include <fstream>
#include <iostream>
using namespace std;

ifstream f("mins.in");
ofstream g("mins.out");

const int maxn = 1000002;

int ciurn[maxn], ciurp[maxn];
int n,m,c,d,t;

void ciur()
{
    for (int i=2; i<=n; i++)
    {
        if(ciurn[i] == 0)
        {
            for(int j = i; j <= n; j += i)
                ciurn[j]++;

            long long k = 1LL * i * i;

            for(long long jj = k; jj <= n; jj += k)
                ciurp[jj] = 1;
        }
        if(ciurp[i] == 0)
        {
            long long t = 1LL * (c / i) * (d / i);
            if(ciurn[i] % 2 == 0)
                m += t;
            else
                m -= t;
        }
    }
}

int main()
{
    f>>c>>d;
    c--;
    d--;

    n = min(c,d);
    m= 1LL * c * d;

    ciur();

    g<<m;
    return 0;


}