Cod sursa(job #1116849)

Utilizator mysu02Mihaita Cornestean mysu02 Data 22 februarie 2014 21:00:25
Problema Fractii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <fstream>

using namespace std;

int main()
{fstream f("fractii.in",ios::in);
 fstream g("fractii.out",ios::out);
 char ok;
 unsigned long n,min,i,j,l,nr;
 f>>n;
 nr=1+2*(n-1);
 for(i=2;i<=n;i++)
 {for(j=2;j<=n;j++)
  {ok='1';
   if(i<j)
   min=i;
   else
   min=j;
   if(i%j==0 && j%i==0)
   ok='0';
   else
   {for(l=2;l<=min;l++)
    {if(i%l==0 && j%l==0)
     ok='0';
     l=min;
    }
    if(ok=='1')
    nr++;
   }
  }
 }
 g<<nr;
 f.close();
 g.close();
    return 0;
}