Pagini recente » Cod sursa (job #1202081) | Cod sursa (job #49421) | Cod sursa (job #2762670) | Cod sursa (job #2974250) | Cod sursa (job #2312115)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("nunta.in");
ofstream g("nunta.out");
typedef long long lint;
typedef unsigned long long ulint;
typedef int huge[1005];
int n, i;
huge a, b, c;
void cpy(huge to, huge from) {
for(int i = from[0]; i >= 0; i --) {
to[i] = from[i];
}
}
void add(huge s, huge x, huge y) {
int i = 0, sum = 0;
bool ok = true;
for(i = 1; ok == true; i ++) {
s[i] = (i <= x[0] ? x[i] : 0) + (i <= y[0] ? y[i] : 0) + sum;
sum = s[i] / 10;
s[i] %= 10;
if(i >= x[0] && i >= y[0] && sum == 0) {
s[0] = i;
ok = false;
}
}
}
void print(huge x) {
for(int i = x[0]; i >= 1; i --) {
g << x[i];
}
}
int main()
{
f >> n;
if(n == 1) {
g << 1; return 0;
}
a[0] = 1; a[1] = 1;
b[0] = 1; b[1] = 1;
for(i = 2; i <= n; i ++) {
add(c, a, b);
cpy(a, b);
cpy(b, c);
}
print(c);
//g << c << '\n';
f.close();
g.close();
return 0;
}