Cod sursa(job #2169876)
Utilizator | Gafton Dinu dinugafton | Data | 14 martie 2018 18:37:37 |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 kb |
#include<bits/stdc++.h>
using namespace std;
int main()
{
ifstream fin("fact.in.txt");
ofstream fout("fact.out");
unsigned long long n,a;
int p,k=0,i=1;
fin>>p;n=1;
while(k!=p||n<=100000000000000000)
{
n=n*i;
i++;a=n;
for(int k1=1;k1<=p;k1++)
if(a%10==0)
{
k++;
a=a/10;
}
else
break;
if(k==p)
{
fout<<n;
break;
}
if(n>=100000000000000000)fout<<"-1";
}
}