Cod sursa(job #2025313)

Utilizator cella.florescuCella Florescu cella.florescu Data 22 septembrie 2017 15:43:05
Problema Nunta Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.61 kb
#include <cstdio>
using namespace std; const int BASE = 10;const int DIG = 209; struct Huge {unsigned char v[DIG];Huge () {for (int i = 0; i < DIG; ++i)v[i] = 0;}Huge operator + (const Huge &other) const {Huge aux;int i, t = 0;for (i = 1; i <= v[0] || t > 0; ++i, t /= BASE)aux.v[i] = (t += (int)v[i] + (int)other.v[i]) % BASE;aux.v[0] = i - 1;return aux;}} a, b, c; int main(){int n, ind;fscanf(fopen("nunta.in", "r"), "%d", &n);a.v[0] = a.v[1] = ind = 1;b = c = a;for (int i = 1; i < n; ++i) {c = a + b;a = b; b = c;}FILE *fout = fopen("nunta.out", "w");for (int i = c.v[0]; i > 0; --i)fprintf(fout, "%d", c.v[i]);return 0;}