Pagini recente » Cod sursa (job #918031) | Cod sursa (job #2923856) | Cod sursa (job #2132029) | Cod sursa (job #644545) | Cod sursa (job #1022457)
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("nunta.in");
ofstream fout("nunta.out");
const int base= 10;
void h_write( vector <int> x ) {
for ( int i= (int)x.size()-1; i>=0; --i ) {
fout<<x[i];
}
fout<<"\n";
}
void hh_add( vector <int> &x, vector <int> y ) {
int t= 0;
for ( int i= 0; i<(int)x.size() || i<(int)y.size() || t>0; ++i ) {
if ( i>=(int)x.size() ) {
x.push_back(0);
}
x[i]+= y[i]+t;
t= x[i]/base;
x[i]%= base;
}
}
int main( ) {
int n;
fin>>n;
if ( n<=3 ) {
fout<<n<<"\n";
return 0;
}
n-= 3;
vector <int> f1, f2;
f1.push_back(3);
f2.push_back(2);
while ( n>0 ) {
vector <int> aux= f1;
hh_add(f1,f2);
f2= aux;
--n;
}
h_write(f1);
return 0;
}