Mai intai trebuie sa te autentifici.
Cod sursa(job #1504180)
Utilizator | Data | 17 octombrie 2015 14:42:13 | |
---|---|---|---|
Problema | Fractii | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int cmmdc(int a,int b)
{int r;
while (b!=0)
{r=a%b;
a=b;
b=r;
}
return a;
}
int numara_fractii(int n)
{
int i=1,nr=0;
int j;
while(i<n)
{
for(j=i+1;j<=n;j++)
if(cmmdc(i,j)==1)
nr++;
i++;
}
return nr*2+1;
}
int n;
int main()
{
fin>>n;
fout<<numara_fractii(n);
return 0;
}