Cod sursa(job #2848847)

Utilizator vladutzu_finutzuVlad Cacenschi vladutzu_finutzu Data 14 februarie 2022 07:48:27
Problema Mins Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.49 kb
#include <fstream>
using namespace std;
ifstream cin("mins.in");
ofstream cout("mins.out");
int c, d;
int cnt[1000005];
int main() {
    cin>>c>>d;
    if(c > d)
        swap(c, d);
    
    long long nr_p = 0;
    for(int i=2; i < c; i++)
    {
        if(cnt[i] - 1 == 0)
            continue;
        
        nr_p -= (cnt[i] - 1) * (c-1)/i * (d-1)/i;
        
        for(int j=i*2; j < c; j+=i)
            cnt[j] -= (cnt[i] - 1);
    }
    
    cout<<1LL * (c-1) * (d-1) - nr_p;
    return 0;
}