Cod sursa(job #393340)
| Utilizator | Data | 9 februarie 2010 11:48:22 | |
|---|---|---|---|
| Problema | Factorial | Scor | 25 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.6 kb |
/*
* File: main.cpp
* Author: virtualdemon
*
* Created on February 9, 2010, 11:32 AM
*/
#include <fstream>
/*
*
*/
using namespace std;
int main( void )
{
unsigned long long int p, i, j, f=0, nr=0;
ifstream in("fact.in");
in>>p;
for( i=1; ; ++i )
{
for( j=i, nr=0; 0 == j%5; ++nr, j/=5 );
f+=nr;
if( f == p )
{
ofstream out("fact.out");
out<<i<<'\n';
return 0;
}
if( f > p )
{
ofstream out("fact.out");
out<<-1;
return 0;
}
}
return 0;
}