Cod sursa(job #1512979)
Utilizator | Data | 28 octombrie 2015 20:56:53 | |
---|---|---|---|
Problema | Factorial | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.35 kb |
#include <iostream>
#include<fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int fct(int p)
{if(p<2)return -1;
if(p%5==0)return p*4+5;
int i=5;
while(p>0)
{
int j=i;
while(j%5==0)
{
p--;
j/=5;
}
i+=5;
}
return i-5;
}
int main()
{int p;
f>>p;
g<<fct(p);
return 0;
}