Cod sursa(job #3378892)
| Utilizator | Data | 28 noiembrie 2026 18:56:19 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.55 kb |
// Source: https://usaco.guide/general/io
#include <bits/stdc++.h>
using namespace std;
int z(int n){
int s=0;
while (n){
n/=5;
s+=n;
}
return s;
}
int main() {
ifstream cin"(fact.in)";
ofstream cout"(fact.out)";
int p;
cin >>p;
int st=1;
int dr=1e8;
int s=-1;
while(st<=dr)
{
int mid=(st+dr)/2;
if(z(mid)>=p)
{
s=mid;
dr=mid-1;
}
else
{
st=mid+1;
}
}
if(z(s)!=p)cout<<"-1\n";else
cout<<s<<"\n";
return 0;
}
