Cod sursa(job #2998781)

Utilizator silivestruSilvestru Visarion silivestru Data 9 martie 2023 23:04:17
Problema Fractii Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.44 kb
#include<fstream>
using namespace std;
ifstream f("fractii.in");
ofstream g("fractii.out");
long long unsigned N,P,Q,a,b,nf=0;
int main()
{f>>N;
P=2;
nf=N;
while(P<=N)
   {Q=1;
    while(Q<=N)
        {a=P;
        b=Q;
        while(a!=b)
            if(a>b)
              a=a-b;
            else
              b=b-a;
        if (a==1)
                nf++;
         Q++;}
    P++;}
g<<nf;
f.close();
g.close();
return 0;
}