Cod sursa(job #2062283)
| Utilizator | Data | 10 noiembrie 2017 10:27:29 | |
|---|---|---|---|
| Problema | Factorial | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.53 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
long long zero(int n){
if(n==0){
return 0;
}
return n/5+zero(n/5);
}
int main()
{
int p;
fin>>p;
if(p==0){
fout<<1;
return 0;
}
int pas=1<<30,s=0;
while(pas!=0){
cout<<s+pas<<"\n";
if(zero(s+pas)<=p){
s+=pas;
}
pas/=2;
}
if(zero(s)==p){
fout<<s-4;
}
else{
fout<<"-1";
}
return 0;
}
