Cod sursa(job #2376253)
| Utilizator | Data | 8 martie 2019 14:29:49 | |
|---|---|---|---|
| Problema | Factorial | Scor | 15 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int r(int t){
int o=0;
while(t%25==0)
{
o++;
t=t/25;
}
return o;
}
int main()
{
long long n,p,k=0,j,a,i,s=0;
in>>n;
a=n;
a++;
if (n==0)out<<1;
else {
for(i=1; i<=n; i++)
{
s=s+5;
if(s%25==0){n-=r(s);}
}
for(i=1; i<=a; i++)
{
k=k+5;
if(k%25==0){a-=r(k);}
}
if(k==s){out<<-1;}
else {out<<s;}
}
return 0;
}
