Cod sursa(job #1498216)
Utilizator | Data | 8 octombrie 2015 09:50:30 | |
---|---|---|---|
Problema | Fractii | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fractii.in");
ofstream g("fractii.out");
int main()
{
int n,p,q,s,r=0,a,b,w;
f>>n;
s=n*2-1;
for(p=2;p<=n;p++)
for(q=p+1;q<=n;q++)
{
a=q;
b=p;
while(b)
{
w=a%b;
a=b;
b=w;
}
if(a==1)
r++;
}
g<<s+2*r;
return 0;
}