Cod sursa(job #1561859)
Utilizator | Data | 4 ianuarie 2016 17:02:03 | |
---|---|---|---|
Problema | Factorial | Scor | 85 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int s,d,m,p,n,x;
int main()
{
f>>p;
if(p==0) g<<1;
else
{
s=1;d=800000000;
while(s<=d && n!=p)
{
n=0;
m=(s+d)/2;
x=m/5;
while(x){
n+=x;x/=5;}
if(n>p) d=m-1;
else s=m+1;
}}
g<<m-m%5;
return 0;
}