Mai intai trebuie sa te autentifici.
Cod sursa(job #2062281)
Utilizator | Data | 10 noiembrie 2017 10:26:26 | |
---|---|---|---|
Problema | Factorial | Scor | 95 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.48 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;
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;
}