Cod sursa(job #2084982)

Utilizator OlivianOlivian Dan Cretu Olivian Data 9 decembrie 2017 14:15:19
Problema Nunta Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.37 kb
#include<cstdio>
using namespace std;
int main()
{
    freopen("nunta.in","r",stdin);
    freopen("nunta.out","w",stdout);
    long a,b;
    int n;
    a=1;b=2;
    scanf("%d",&n);
    if(n<=3) printf("%d",n);
    else
    {
        for(n;n>=3;n--)
        if(a>b) b=b+a;
        else a=a+b;
        if(b>a) printf("%d",b);
        else printf("%d",a);
    }
}