Cod sursa(job #3175409)

Utilizator xXoctavianXxStanescu Matei Octavian xXoctavianXx Data 25 noiembrie 2023 19:14:43
Problema Mins Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <bits/stdc++.h>
#define int long long

using namespace std;

ifstream fin("mins.in");
ofstream fout("mins.out");

int c,d;

const int cmax = 1e6+6;
int mob[cmax];

void init_ciur()
{
    for(int i=2; i<cmax; i++) mob[i] = 1;

    for(int i=2; i<cmax; i++)
    {
        if(mob[i] == 0) continue;

        for(int j = 2*i; j < cmax; j += i)
        {
            mob[j] -= mob[i];
        }
    }
}

signed main()
{
    init_ciur();
    fin>>c>>d;
    int rasp = (c-1) * (d-1);
    for(int i=2; i<cmax; i++)
    {
        rasp -= mob[i] * ((c-1) / i) * ((d-1) / i);
    }
    fout<<rasp;
    return 0;
}