Cod sursa(job #1435563)
| Utilizator | Data | 13 mai 2015 19:50:10 | |
|---|---|---|---|
| Problema | Factorial | Scor | 95 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <iostream>
#include <fstream>
using namespace std;
int puteremax(int n){
int s=1;
while(s<=n){
s=5*s;
}
return s/5;}
int main()
{ ifstream in("fact.in");
ofstream out("fact.out");
int k;
in>>k;
int i;
i=4*k;
if(k==0) out<<"1";
int ok=1;
while(k>0&&i<=5*k&&ok==1){
int x=puteremax(i);
int s=0;
while(x>1){
s=s+i/x;
x=x/5;
}
if(s==k){
ok=0;
out<<i;}
else i++;
}
if(ok==1&&k>0) out<<"-1";
return 0;}
