Cod sursa(job #2846781)

Utilizator chiriacandrei25Chiriac Andrei chiriacandrei25 Data 9 februarie 2022 17:39:47
Problema Mins Scor 80
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <fstream>

using namespace std;

const int Cmax = 1000005;

int cnt[Cmax];

int main() {
    int c, d;
    ifstream fin("mins.in");
    ofstream fout("mins.out");
    fin >> c >> d;
    c--; d--;
    long long nr_p = 0;
    for(int k = 2; k <= min(c, d); k++) {
        int x = 1 - cnt[k];
        nr_p += 1LL * x * (c / k) * (d / k);
        for(int m = 2 * k; m <= min(c, d); m += k) {
            cnt[m] += x;
        }
    }
    fout << 1LL * c * d - nr_p;
    return 0;
}