Cod sursa(job #903737)
Utilizator | Data | 2 martie 2013 18:13:12 | |
---|---|---|---|
Problema | Factorial | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.32 kb |
#include<fstream>
using namespace std;long n,p;ifstream f("fact.in");ofstream g("fact.out");long z(long x){long c=5,d=0;while(c<=x){d+=(x/c);c*=5;}return d;}long vs(long s,long d){if(z(s)==p)return s;if(s<d){long m=(d+s)/2;if(z(m)>=p)return vs(s+1,m);else return vs(m+1,d);}return -1;}int main(){f>>p;g<<vs(1,int(2e9));return 0;}