Cod sursa(job #1987547)
| Utilizator | Data | 31 mai 2017 00:10:18 | |
|---|---|---|---|
| Problema | Factorial | Scor | 5 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <fstream>
#define LONG_LONG_MAX 9223372036854775807LL
using namespace std;
int zero( int n ){
int z=0;
while ( n>=5 ){
if ( n%5==0 )
z++; n/=5;
}
return z;
}
int main()
{
ifstream in("fact.in");
ofstream out("fact.out");
long p; in>>p;
if( p==0 ) out<<1;
long sum=0;
for(long long i=5; i<=LONG_LONG_MAX; i+=5 ){
sum+=zero(i);
if(sum==p) { out<<i; break; }
}
return 0;
}
