Mai intai trebuie sa te autentifici.
Cod sursa(job #930352)
| Utilizator | Data | 27 martie 2013 16:33:30 | |
|---|---|---|---|
| Problema | Factorial | Scor | 5 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.74 kb |
#include<cstdio>
using namespace std;
long long i, n, st, dr, mij, x;
long long corect(long long x){
long long rez; rez=0;
while (x>=5) {rez+=x/5; x=x/5;}
if (rez>=n) return 0; else return 1;
}
long long corectfix(long long x){
long long rez; rez=0;
while (x>=5) {rez+=x/5; x=x/5;}
if (rez==n) return true; else return false;
}
int main(){
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
scanf("%lld", &n);
st=1; dr=10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10*10;
while (dr-st>=2) {
mij=(st+dr)/2;
x=corect(mij);
if (x==0) dr=mij; else st=mij;
}
if (corectfix(st)==true) printf("%lld\n", st); else printf("%lld\n", dr);
return 0;
}
