Cod sursa(job #1399698)
| Utilizator | Data | 24 martie 2015 21:25:24 | |
|---|---|---|---|
| Problema | Factorial | Scor | 30 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.64 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int x,p,y,i,j,nr;
ifstream f("fact.in");
ofstream g("fact.out");
f>>p;
x=5*p;
y=p;
if (p==0)
g<<1;
else
{
for (i=5;i<=y;i+=5)
{
j=i;
while (j%5==0)
{
j=j/5;
x-=5;
y--;
}
}
}
for (i=5;i<x-1;i+=5)
{
j=i;
nr=0;
while (j%5==0)
{
nr++;
j=j/5;
}
}
if (nr==p) g<<-1;
else g<<x;
return 0;
}
