Cod sursa(job #2534936)
| Utilizator | Data | 31 ianuarie 2020 09:51:57 | |
|---|---|---|---|
| Problema | Factorial | Scor | 50 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.55 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("fact.in");
ofstream fout ("fact.out");
int zerouri(int x)
{
int cnt=0;
while(x>0)
{
cnt+=x/5;
x/=5;
}
return cnt;
}
int main()
{
int p,step,pos;
fin >> p;
step=1;
while(step<100000000)
step=step<<1;
step=step>>1;
pos=0;
while(step>0)
{
if(pos+step<=100000000 && zerouri(step+pos)<p)
pos+=step;
step=step>>1;
}
fout << pos+1;
return 0;
}
