Cod sursa(job #3226422)

Utilizator Dragos__1_1Dragos Antohi Dragos__1_1 Data 21 aprilie 2024 13:10:32
Problema Mins Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.97 kb
/*#include <bits/stdc++.h>
using namespace std;
ifstream f("mins.in");
ofstream g("mins.out");
int i,j,c,d,dx,dy,k;
struct pct {int x; int y;}v[100001];
bool cmp(pct a,pct b)
{   if (a.x<b.x||a.x==b.x&&a.y<b.y)return 1;
    return 0;
}
int main()
{   f>>c>>d;
    for (i=1;i<c;i++)
        for (j=1;j<d;j++)
        {   int dm=__gcd(i,j);
            v[++k]={i/dm,j/dm};
        }
    int l=1;
    sort (v+1,v+1+k,cmp);
    for (i=2;i<=k;i++){
        if (!(v[i].x==v[i-1].x&&v[i].y==v[i-1].y))l++;
    }
    g<<l<<'\n';
    return 0;
}
*/

#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream f("mins.in");
ofstream g("mins.out");
ll c,d,n,pairs;
ll i,j;
ll v[1000002];
int main()
{
    f>>c>>d;c--;d--;if (c>=d)n=c;else n=d;
    for (i=n;i>0;i--)
    {   pairs = 1ll*(1ll*c/i)*(1ll*d/i);
        for (j=i+i;j<=n;j+=i){
            pairs-=0ll+v[j];
        }
        v[i]=0ll+pairs;
    }
    g<<v[1]<<'\n';
    return 0;
}