Pagini recente » Cod sursa (job #2487344) | Cod sursa (job #193690) | Cod sursa (job #476052) | Cod sursa (job #424949) | Cod sursa (job #2023780)
#include <bits/stdc++.h>
using namespace std;
const int BASE = 10;
struct Huge {
int numcif;
int v[1000];
Huge () {
numcif = 0;
memset(v, 0, sizeof v);
}
Huge operator + (const Huge &other) const {
Huge aux;
int i, t = 0;
for (i = 1; i <= numcif || t; ++i, t /= BASE)
aux.v[i] = (t += v[i] + other.v[i]) % BASE;
aux.numcif = i - 1;
return aux;
}
} q[4];
int main()
{
int n, ind;
ifstream fin("nunta.in");
fin >> n;
fin.close();
q[0].numcif = q[1].numcif = q[0].v[1] = q[1].v[1] = ind = 1;
for (int i = 1; i < n; ++i) {
ind = ((ind + 1) & 3);
q[ind] = q[(ind + 3) & 3] + q[(ind + 2) & 3];
}
ofstream fout("nunta.out");
for (int i = q[ind].numcif; i > 0; --i)
fout << q[ind].v[i];
fout.close();
return 0;
}