Cod sursa(job #2699812)
| Utilizator | Data | 25 ianuarie 2021 21:58:17 | |
|---|---|---|---|
| Problema | Fractii | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.44 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
long long int n;
int gcd(int a,int b) {
if (b == 0)
return a;
else
return gcd(b, (a % b));
}
void solve()
{
long long int s=n;
for(int i=2;i<n;i++) {
for(int j=1;j<=n;j++){
if(gcd(i,j)==1) s+=1;
}
}
fout<<s;
}
int main()
{
fin>>n;
solve();
}
