Pagini recente » Istoria paginii runda/splunge4/clasament | Istoria paginii runda/baraj2010_ziua2/clasament | Cod sursa (job #3296659) | Cod sursa (job #1482807) | Cod sursa (job #564156)
Cod sursa(job #564156)
#include <fstream>
using namespace std;
long int n,sol[10],nr=0;
ifstream f("fractii.in");
ofstream g("fractii.out");
int cmd(long int a, long int b)
{long int c;
if(b>a){
c=a;
a=b;
b=c;
}
c=a%b;
while(c!=0)
{
a=b;
b=c;
c=a%b;
}
if(b==1) return 1;
else return 0;
}
void init(int k)
{
sol[k]=0;
}
int succesor(int k)
{
if(sol[k]<n){
sol[k]++;
return 1;
}else{
return 0;
}
}
int valid(int k)
{
return 1;
}
int solutie(int k)
{
return k==3;
}
void tipar()
{
if(cmd(sol[1],sol[2])==1) nr=nr+1;
}
void back(int k)
{
if(solutie(k)) tipar();
else{
init(k);
while(succesor(k)) if(valid(k)) back(k+1);
}
}
int main()
{
f>>n;
back(1);
g<<nr;
f.close();
g.close();
}