Cod sursa(job #1734524)

Utilizator MihalachiRazvanMihalachi Razvan MihalachiRazvan Data 27 iulie 2016 16:21:30
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.76 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 aux,y,x,k=1;
    x=6;
    y=5;
    while(x+y<p)
    {
        y=y+x;
        k++;
    }
    if(x+y==p)
        return 0;
    else
         return k;

}
int main()
{
    fin>>p;
      if(p==0)
        fout<<1;
        else if(p==1)
        fout<<5;
        else
        {
            n=p*5;
            if(scadere(p)==0)
                fout<<-1;
                else if(p>=31)
                fout<<n-(5*(scadere(p)))-scadere(p);
                else
                fout<<n-(5*(scadere(p)));



        }

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