Mai intai trebuie sa te autentifici.
Cod sursa(job #1220338)
Utilizator | Data | 17 august 2014 01:50:52 | |
---|---|---|---|
Problema | Fractii | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.64 kb |
#include <iostream>
#include <math.h>
#include <fstream>
using namespace std;
ifstream f("fractii.in");
ofstream g("fractii.out");
int main()
{
int n, x = 0;
f>>n;
for (int i = 1; i <= n; i ++)
{
for (int j = 1; j <= n; j ++)
{
int a = i, b = j;
while (a != b)
{
if (a > b)
{
a = a - b;
}
else
{
b = b - a;
}
}
if (a == 1)
{
x = x + 1;
}
}
}
g<<x;
return 0;
}