Cod sursa(job #3356050)
| Utilizator | Data | 29 mai 2026 03:41:32 | |
|---|---|---|---|
| Problema | Fractii | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.34 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{long n,x,y,d,nb=0,a,b;
ifstream f("fractii.in");
ofstream g("fractii.out");
f>>n;
for (a=1; a<=n;a++)
for (b=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++;
}
g<<nb;
g.close();
return 0;
}
