Cod sursa(job #2438171)
| Utilizator | Data | 11 iulie 2019 15:33:37 | |
|---|---|---|---|
| Problema | Factorial | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");
int p;
int sol(int x)
{
int t=5,cont=0,aux;
while(x>=t)
{
x/=t;
cont+=x;
}
return cont;
}
int cb()
{
int poz=0;
for(int i=(1<<30);i>0;i=i/2)
{
if(poz+i<=1000000005)
{
if(sol(poz+i)<p)
{
poz+=i;
}
}
}
if(sol(poz+1)==p)
return poz+1;
else return -1;
}
int main()
{
in>>p;
out<<cb();
return 0;
}
