Cod sursa(job #1927581)

Utilizator iulianrotaruRotaru Gheorghe-Iulian iulianrotaru Data 15 martie 2017 11:49:14
Problema Dreptunghiuri Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.39 kb
#include <bits/stdc++.h>
using namespace std;
ifstream f("dreptunghiuri.in");
ofstream g("dreptunghiuri.out");
int i,j,x,y,a,b,A,B;
long long s;
int main()
{
    f>>x>>y;
    for(i=1;i<=x;++i)
        for(j=0;j<=y;++j)
        if(__gcd(i,j)==1)
            for(a=1;a*i<=x;++a)
                for(b=1,A=a*i+j,B=a*j+i;A<=x&&B<=y;++b,A+=j,B+=i) s+=(x-A)*(y-B);
    g<<s;
    return 0;
}