Cod sursa(job #923129)

Utilizator SagunistuStrimbu Alexandru Sagunistu Data 23 martie 2013 11:40:32
Problema Factorial Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <iostream>
#include <fstream>

using namespace std;

int main()
{ifstream fin("fact.in");
ofstream fout("fact.out");
int p,i,j,ok;
fin>>p;
if(p==0)
    fout<<"1";
else
{j=0;
i=0;
ok=1;
while(1)
    {i++;
     j+=5;
     if(i%5==0)
        i++;
     if(i==p)
        break;
     else
     if(i>p)
        {break;
         ok=0;
        }
    }
if(ok==0)
    fout<<"-1";
else
    fout<<j;
}
    return 0;
}