Pagini recente » Cod sursa (job #876690) | Cod sursa (job #2025315)
#include <cstdio>
#include <cstring>
using namespace std;
const int BASE = 10;
const int DIG = 209;
unsigned char a[DIG], b[DIG], c[DIG];
int main()
{
int n, j;
fscanf(fopen("nunta.in", "r"), "%d", &n);
a[0] = a[1] = b[0] = b[1] = 1;
for (int i = 1; i < n; ++i) {
int t = 0;
for (j = 1; j <= b[0] || t; ++j, t /= BASE)
c[j] = (t += a[j] + b[j]) % BASE;
c[0] = j - 1;
memcpy(a, b, sizeof b);
memcpy(b, c, sizeof c);
}
FILE *fout = fopen("nunta.out", "w");
for (int i = c[0]; i > 0; --i)
fprintf(fout, "%d", c[i]);
return 0;
}