Cod sursa(job #1823458)

Utilizator ionanghelinaIonut Anghelina ionanghelina Data 6 decembrie 2016 13:14:04
Problema Nunta Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 kb
#include<bits/stdc++.h>
using namespace std;
long long f1,f2,f3;
int n;
int main()
{
    freopen("nunta.in","r",stdin);
    freopen("nunta.out","w",stdout);
    scanf("%d",&n);
    if(n==1) printf("1\n");
        else
    if(n==2) printf("2\n");
        else
    {
        f1=1LL;
        f2=2LL;
        for(int i=3;i<=n;i++)
        {
            f3=f1+f2;
            f1=f2;
            f2=f3;
        }
        printf("%lld\n",f3);
    }
    return 0;
}