Pagini recente » Cod sursa (job #2645385) | Cod sursa (job #1869657) | Cod sursa (job #2127871) | Istoria paginii runda/simulare-cartita-42/clasament | Cod sursa (job #236877)
Cod sursa(job #236877)
/***************************************************************************
* Copyright (C) 2008 by cata,,, *
* cata@cata-laptop *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <iostream>
#include <cstdlib>
#include<fstream>
using namespace std;
ifstream f("/home/cata/te/src/fractii.in");
ofstream g("/home/cata/te/src/fractii.out");
long cmmdc(long long a, long long b)
{
while(b!=0)
{long long r = a%b;
a=b;
b=r;
}
return a;
}
int main(int argc, char *argv[])
{
long long n, a,b,nr=0;
if(f.is_open())
f>>n;
else cout<<"er";
for(a=2;a<=n;a++)
for(b=a+1;b<=n;b=b+1)
if( cmmdc(a,b)==1)
{//cout<<a<<" "<<b<<" "<<cmmdc(a,b)<<endl;
nr=nr+2;}
g<<nr+2*n-1;
f.close();
g.close();
return EXIT_SUCCESS;
}