Pagini recente » Clasamentul arhivei de probleme | Cod sursa (job #748676) | Cod sursa (job #2662475) | Cod sursa (job #903452) | Cod sursa (job #2251080)
#include <iostream>
#include <fstream>
using namespace std;
int n,sol=0,v[3]={0};
ifstream fin("fractii.in");
ofstream fout("fractii.out");
void Retsol()
{
sol++;
}
int Cont(int k)
{
if(k==1) return 1;
if((v[1]%v[2]==0 || v[2]%v[1]==0) && v[1]!=1 && v[2]!=1) return 0;
return 1;
}
void Back()
{
int k=1;
while(k>0)
{
if(k>2)
{
Retsol();
k--;
}
else
if(v[k]<n)
{
v[k]++;
if(Cont(k))
k++;
}
else
{
v[k]=0;
k--;
}
}
}
int main()
{
fin>>n;
Back();
fout<<sol;
return 0;
}