Cod sursa(job #2849068)

Utilizator octavi26octavian octavi26 Data 14 februarie 2022 15:01:46
Problema Mins Scor 85
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.66 kb
#include <bits/stdc++.h>
#define N 1000008

using namespace std;

using ll = long long;

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

int c, d;
int cnt[N];

ll sol;

void Citire()
{
    fin >> c >> d;
    c--;
    d--;
    if (d < c) swap(c, d);
}

void Rezolvare()
{
    int i, j;
    for( int i = 2; i <= c; ++i )
    {
        if( cnt[i] == 1 ) continue;

        int k = 1 - cnt[i];
        sol += 1LL * k * (c / i) * (d / i);

        for( j = 2 * i; j <= c; j += i)
            cnt[j] = cnt[j] + k;
    }
    fout << 1LL * c * d - sol;
}

int main()
{
    Citire();
    Rezolvare();
    fin.close();
    fout.close();
}