Cod sursa(job #1219991)
| Utilizator | Data | 16 august 2014 11:27:28 | |
|---|---|---|---|
| Problema | Factorial | Scor | 55 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.48 kb |
#include <iostream>
#include <fstream>
#include <stdio.h>
using namespace std;
int main()
{
unsigned long i = 1, aux = 0;
long P = 0;
ifstream f ( "fact.in" );
f >> P;
f.close();
if ( P > 0 )
{
for ( i = 5; P > 0; i += 5 )
{
aux = i;
while ( aux % 5 == 0 )
{
P--;
aux = aux / 5;
}
}
i -= 5;
}
else
{
i = 1;
}
ofstream g ( "fact.out" );
if ( P == 0 ) g << i;
else g << -1;
g.close();
return 0;
}
