Cod sursa(job #2310255)
| Utilizator | Data | 30 decembrie 2018 21:20:32 | |
|---|---|---|---|
| Problema | Factorial | Scor | 20 |
| Compilator | cpp-32 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.46 kb |
#include<bits/stdc++.h>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
typedef long long ll;
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(0);
cout.tie(0);
ll n;in>>n;
ll i=5;
if(n==0)return out<<"1",0;
while(n>0){
ll x=i;
int sum=0;
while(x%5==0)++sum,x/=5;
n-=sum;
i+=5;
}
if(n==0)out<<i-5<<'\n';
else out<<"-1";
return 0;
}
