Cod sursa(job #2028404)

Utilizator theoioanaTheodoraD theoioana Data 27 septembrie 2017 21:03:44
Problema Fractii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.97 kb
#include<iostream>
#include<fstream>
#include<cmath>


using namespace std;

ifstream f("fractii.in");
ofstream fout("fractii.out");

int n, i, j, nr, ok, maxx,k;

int main(){

         while( f>>n ){

                  nr=0;
                  for( i=1; i<=n; i++)
                           for( j=1; j<=n;j++){
                                    ok=1;
                                    if( i>=j)
                                             maxx=i;
                                    else
                                             maxx=j;
                                    for( k=2; k<=maxx; k++)
                                             if(maxx%k==0 && i%k==0 && j%k==0)
                                                      ok=0;
                                    if( j==1 || ( i%j!=0 && ok==1 ))
                                             nr++;

                           }
                  fout<<nr<<'\n';
         }



return 0;
}