Cod sursa(job #2080201)
Utilizator | Data | 2 decembrie 2017 16:03:07 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int P;
int zerouri(int x)
{
int ans=0;
while(x>=5)
ans+=(x/=5);
return ans;
}
int main()
{
int r=0, pas=1<<28, p;
f>>p;
while(pas)
{
if(zerouri(r+pas)<p)
r+=pas;
pas/=2;
}
r++;
if(zerouri(r)!=p) r=-1;
g << r;
return 0;
f.close();
g.close();
}