Cod sursa(job #3356051)

Utilizator Emma_PEmma Piven Emma_P Data 29 mai 2026 05:03:01
Problema Fractii Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.35 kb
#include <iostream>
#include <fstream>
using namespace std;

int main()
{long n,x,y,d,nb=1,a,b;

ifstream f("fractii.in");
ofstream g("fractii.out");
f>>n;
cout<<n;
for (a=1; a<=n-1;a++)
    for (b=a+1;b<=n;b++)
{
x=a;
y=b;
while (x!=y)
{
    if (x>y) x=x-y;
    else y=y-x;
}
if (x==1) nb=nb+2;
}
g<<nb;
g.close();
    return 0;
}