Cod sursa(job #2470483)
Utilizator | Data | 9 octombrie 2019 11:59:30 | |
---|---|---|---|
Problema | Factorial | Scor | 40 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main()
{
int p,n,a=5,b,no=0;
fin>>p;
while(no<p)
{
b=a;
b/=5;
while(b%5==0)
{
b/=5;
no++;
}
no++;
a+=5;
}
if(a==0)
fout<<"1";
else if (p!=no) fout<<"-1";
else fout<<a-5;
return 0;
}