Pagini recente » Cod sursa (job #2872530) | Cod sursa (job #1333523) | Cod sursa (job #57088) | Cod sursa (job #1192861) | Cod sursa (job #525669)
Cod sursa(job #525669)
#include <cstdio>
#include <vector>
using namespace std;
int main()
{
freopen ("fractii.in","r",stdin);
freopen ("fractii.out","w",stdout);
int n,anz=1,anf=1,x,i,j;
bool fertig=false;
vector <int> bruche (3);
bruche[1]=1;
bruche[2]=1;
scanf ("%d",&n);
while (fertig==false)
{
x=bruche.size();
for (int t=anf;t<x;t+=2)
{
i=bruche[t];
j=bruche[t+1];
if ((i+j)<=n)
{
anz+=2;
bruche.push_back(i+j);
bruche.push_back(j);
bruche.push_back(i);
bruche.push_back(i+j);
}
else
fertig=true;
}
anf=anf*2+1;
}
printf ("%d", anz);
return 0;
}