Cod sursa(job #632618)

Utilizator axel79Roman Alexandru Daniel axel79 Data 11 noiembrie 2011 20:21:10
Problema Fractii Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.38 kb

#include<fstream>
using namespace std;
long long x=0,y=0,r=1,n,nr,i,j;
ifstream in("fractii.in");
ofstream out("fractii.out");

int main()
{
    in>>n;nr=0;
    for(i=1;i<=n;i++){

    for(j=1;j<=n;j++){
x=i;y=j;

     while(x!=y){

     if(x>y) x=x-y;
     else y=y-x;}
     if((x==1) || (y==1)) nr++;

     }}
    out<<nr;
in.close();
out.close();
    return 0;
}