Cod sursa(job #3173118)
Utilizator | Padurariu Riccardo Padurariu_Riccardo | Data | 21 noiembrie 2023 21:17:26 |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.78 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main(){
int P,N=0,i,fact,c;
fin >> P;
bool gasit = false;
while(!gasit){
N++;
c=0;
for(i=1;i<=N;i++)
{
if(i%2==0 && i%5==0)
{
while(i%2==0 && i%5==0){
c++;
if(i%2==0)
i/=2;
else
if(i%5==0)
i/=5;
}
}
}
if(c==P)
gasit = true;
else
if(c>P)
gasit = true;
}
if(c==P)
fout << N;
else
fout << "-1";
return 0;
}