Cod sursa(job #1517011)
Utilizator | Data | 3 noiembrie 2015 19:39:47 | |
---|---|---|---|
Problema | Factorial | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.62 kb |
#include <iostream>
#include <fstream>
using namespace std;
int i=1,x,j,z,y=2,P,zero;
int main()
{
ifstream f("fact.in");
ofstream g("fact.out");
f>>P;
while(zero<P)
{
x=i;
while(x%10==0)
x=x/10;
if(((x%10)*(y%10))%10==0)
zero++;
if(i>10)
{
x=i;
j=10;
while(x%10==0)
{
j=j*10;
x=x/10;
}
i=i%j;
}
i=i*y;
y++;
}
if(zero==P)
g<<y-1;
else
g<<-1;
return 0;
}