Cod sursa(job #163164)
| Utilizator | Data | 21 martie 2008 16:04:28 | |
|---|---|---|---|
| Problema | Fractii | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.43 kb |
#include<fstream>
using namespace std;
int f(unsigned x, unsigned y){
while(x != y){
if(x > y) x -= y;
else y -= x;
}
if(x == 1) return 0;
else return 1;
}
int main(){
fstream in("fractii.in", ios::in);
int rezultat = 0; unsigned i, j, n;
in >> n; n++; in.close();
for(i= 1; i < n; i++)
for(j = 1; j < n; j++)
if(!f(i, j)) rezultat++;
fstream out("fractii.out", ios::out);
out << rezultat;
}
