Cod sursa(job #2998771)
Utilizator | Data | 9 martie 2023 22:45:58 | |
---|---|---|---|
Problema | Fractii | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.48 kb |
#include<fstream>
using namespace std;
ifstream f("fractii.in");
ofstream g("fractii.out");
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)
if(P%Q!=0||Q%P!=0)
nf++;
Q++;}
P++;}
g<<nf;
f.close();
g.close();
return 0;
}