Pagini recente » Cod sursa (job #1262947) | Cod sursa (job #1237119) | Cod sursa (job #2861283) | Cod sursa (job #538867) | Cod sursa (job #1576067)
#include <iostream>
#include <fstream>
#include <utility>
#include <set>
using namespace std;
ifstream f("fractii.in");
ofstream g("fractii.out");
std::set<std::pair<int,int> > Set;
int gcd(int a, int b) {
int t;
if(b>a){
t=a;
a=b;
b=t;
}
while (b != 0) {
t = b;
b = a % b;
a = t;
}
return a;
}
int main()
{
int n;
f>>n;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
{
int tmp=gcd(i,j);
Set.insert(make_pair(i/tmp,j/tmp));
}
g<<Set.size();
return 0;
}