Pagini recente » Cod sursa (job #2138026) | Cod sursa (job #41893) | Cod sursa (job #1668956) | Cod sursa (job #1332750) | Cod sursa (job #525670)
Cod sursa(job #525670)
#include <cstdio>
#include <vector>
using namespace std;
int main()
{
int n,anz=1,anf=1,x,i,j,p,aux=1;
bool fertig=false;
vector <int> bruche (3);
bruche[1]=1;
bruche[2]=1;
scanf ("%d",&n);
while (fertig==false)
{
x=bruche.size();
p=0;
for (int t=anf;t<x;t+=2)
{
i=bruche[t];
j=bruche[t+1];
if ((i+j)<=n)
anz+=2;
else
p+=2;
bruche.push_back(i+j);
bruche.push_back(j);
bruche.push_back(i);
bruche.push_back(i+j);
}
aux*=2;
if (p==aux)
fertig=true;
anf=anf*2+1;
}
for (int q=1;q<bruche.size();q+=2)
printf ("%d / %d \n",bruche[q],bruche[q+1]);
printf ("%d", anz);
return 0;
}