Pagini recente » Cod sursa (job #1788627) | Cod sursa (job #148596) | Cod sursa (job #1293597) | Cod sursa (job #957582) | Cod sursa (job #754289)
Cod sursa(job #754289)
#include <fstream>
#include <cstring>
using namespace std;
int N, o;
int v[2][350];
void Citire ()
{
ifstream fin ("nunta.in");
fin >> N;
fin.close ();
}
void Sum ()
{
int j, t = 0;
for (j = 1; j <= v[o][0] || t; j++)
{
v[o][j] += t + v[!o][j];
t = v[o][j] / 10;
v[o][j] %= 10;
}
v[o][0] = j - 1;
}
void Business ()
{
memset (v, 0, sizeof (v));
v[0][0] = 1;
v[0][1] = 1;
v[1][0] = 1;
v[1][1] = 2;
o = 0;
for (int y = 3; y <= N; y++, o = !o)
{
Sum ();
}
ofstream fout ("nunta.out");
o = !o;
for (int i = v[o][0]; i >= 1; i--)
{
fout << v[o][i];
}
fout.close ();
}
int main ()
{
Citire ();
if (N < 3)
{
ofstream fout ("nunta.out");
fout << N;
fout.close ();
return 0;
}
Business ();
return 0;
}