Pagini recente » Cod sursa (job #44319) | Cod sursa (job #60165) | Cod sursa (job #565803) | Cod sursa (job #1078506) | Cod sursa (job #2609164)
#include <bits/stdc++.h>
using namespace std;
ifstream f("text.in");
ofstream g("text.out");
long long poww,x,p,minn,adun,ok;
int main()
{//25 125 625 3125 15625 78125 390625 1953125 9765625 48828125
//5 26 27 127 128 129
f>>p;
if(p==0)
{
g<<1;
return 0;
}
poww=5;
adun=0;
x=0;
ok=1;
while(p>=poww&&ok)
{
if(p>=poww+adun&&p<=poww+adun+x)
ok=0;
x++;
adun+=x;
poww*=5;
}
if(!ok)
{g<<-1;
return 0;
}
x=p*5;
poww=25;
minn=1;
while(poww<x)
{
x-=minn*5;
poww*=5;
minn++;
}
g<<x;
return 0;
}
/*
5
10
15
20
25 *2
30 7
35 8
40
45
50
55
60
65
70
75
80
85
90
95 20
100
105
110
115 24
125 27
*/