Cod sursa(job #1734058)

Utilizator MihalachiRazvanMihalachi Razvan MihalachiRazvan Data 26 iulie 2016 13:36:25
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.63 kb
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int p,n,i;
int scadere(int p)
{
    int x,y,aux;
    x=5;
    y=10;
    while(x+y<p)
    {
       aux=y;
       y=y+x;
       x=aux;
    }
    return x;
}
int main()
{
    fin>>p;
      if(p==0)
        fout<<1;
        else if(p==1)
        fout<<5;

        else
        {
            n=p*5;
            if(p>=2&&p<=4)
                fout<<n;
            else if(p>=6)
              fout<<n-scadere(p);


        }

    fin.close();
    fout.close();
    return 0;
}