Cod sursa(job #3003050)

Utilizator slol003Rizea Alexandru-Gabriel slol003 Data 15 martie 2023 13:33:06
Problema Mins Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.79 kb
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;

const int nmax=1000005;
int cnt[nmax];

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

    return 0;
}