Cod sursa(job #2973464)
| Utilizator | Data | 31 ianuarie 2023 23:07:29 | |
|---|---|---|---|
| Problema | Fractii | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.56 kb |
#include <bits/stdc++.h>
using namespace std;
bool isReductible(int a, int b){
if (a < b) swap(a, b);
while(b){
int t = b;
b = a % t;
a = t;
}
if (a == 1) return true;
else return false;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
freopen("fractii.in", "r", stdin);
freopen("fractii.out", "w", stdout);
int n;
cin >> n;
int ras = 0;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= n; j++)
if (isReductible(i, j)) ras += 1;
}
cout << ras;
return 0;
}