Cod sursa(job #1252100)
| Utilizator | Data | 30 octombrie 2014 13:25:57 | |
|---|---|---|---|
| Problema | Factorial | Scor | 15 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <iostream>
#include <fstream>
using namespace std;
long p;
int zero (int n)
{
long rez;
rez=0;
while(n>=5)
{
rez+=n/5;
n/=5;
}
return rez;
}
int main()
{
int i=0;
ifstream in("fact.in");
ofstream out("fact.out");
in>>p;
in.close();
int pas = 1<<24;
while (pas!=0)
{
if(zero(pas+i)<p)
i+=pas;
pas>>=1;
}
if(zero(i+pas)==p)
out<<i+1;
else
out<<-1;
out.close();
return 0;
}
