Pagini recente » Cod sursa (job #1404918) | Cod sursa (job #877233) | Cod sursa (job #2898405) | Cod sursa (job #621805) | Cod sursa (job #2162725)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("nunta.in");
ofstream fout("nunta.out");
const int base = 1000000000;
struct BigInt {
vector < int > digit;
BigInt operator + (const BigInt &other) {
BigInt ret(0);
int carry = 0;
for(int i = 0; i < (int)digit.size() || i < (int)other.digit.size() || carry; ++i) {
if(i == (int)ret.digit.size()) {
ret.digit.push_back(0);
}
ret.digit[i] += carry + (i < (int)other.digit.size() ? other.digit[i] : 0) + (i < (int)digit.size() ? digit[i] : 0);
carry = (ret.digit[i] >= base);
if(carry) {
ret.digit[i] -= base;
}
}
return ret;
}
BigInt(int x) {
digit.push_back(x);
}
};
int main() {
int n;
fin >> n;
BigInt A(0), B(1), C(1);
for(int i = 0; i < n; ++i) {
C = A + B;
A = B;
B = C;
}
fout << C.digit.back();
for(int i = (int)C.digit.size() - 2; i >= 0; --i) {
for(int j = 0; j < 9 - log10(C.digit[i]) - 1; ++j) {
fout << "0";
}
fout << C.digit[i];
}
return 0;
}