Cod sursa(job #1786578)

Utilizator nurof3nCioc Alex-Andrei nurof3n Data 23 octombrie 2016 12:37:26
Problema Nunta Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream f ("nunta.in");
ofstream g ("nunta.out");
short int N;
int main()
{
    f >> N;
    int M1 = 1, M2 = 2;
    if (N == 0) M2 = 0;
    else if (N == 1) M2 = M1;
    else
    {
        for (short int i = 3; i <= N; i++)
        {
            M2 = M1 + M2;
            M1 = M2;
        }
    }
    g << M2;

    return 0;
}