Pagini recente » Cod sursa (job #2025972) | Cod sursa (job #2006126) | Rating Razvan Balan (raz1vy1) | Atasamentele paginii Clasament preoji2013 | Cod sursa (job #236836)
Cod sursa(job #236836)
/***************************************************************************
* 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("fractii.in");
ofstream g("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";
cout<<n<<endl;
for(a=1;a<=n;a++)
for(b=a+1;b<=n;b++)
if(cmmdc(a,b)==1)
{//cout<<a<<" "<<b<<" "<<cmmdc(a,b)<<endl;
nr++;}
g<<2*nr;
f.close();
g.close();
return EXIT_SUCCESS;
}