Cod sursa(job #393779)
| Utilizator | Data | 9 februarie 2010 22:09:55 | |
|---|---|---|---|
| Problema | Factorial | Scor | 35 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.4 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main(){
fstream fin("fact.in",ios::in);
fstream fout("fact.out",ios::out);
unsigned hp=0,p,k,r=-1;
fin>>p;
if(p!=0){
for(int i=5;hp<p;i+=5){
unsigned c=0;
k=i;
while(k%5==0){
c++;k/=5;
}
hp+=c;
if(hp==p){
r=i;
}
}
fout<<r;
}else{
fout<<-1;
}
fin.close();
fout.close();
}
