Cod sursa(job #1220340)
| Utilizator | Data | 17 august 2014 02:01:21 | |
|---|---|---|---|
| Problema | Fractii | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.74 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, b, rest;
if (i < j)
{
a = j;
b = i;
}
else
{
a = i;
b = j;
}
do
{
rest=a%b;
a=b;
b=rest;
}
while (rest == 1);
if (a == 1)
{
x = x + 1;
}
}
}
g<<x;
return 0;
}
