Cod sursa(job #2698417)

Utilizator GheorgheBBalamatiuc Gheorghe GheorgheB Data 22 ianuarie 2021 00:25:25
Problema Factorial Scor 5
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.32 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int main(){
	int p, k=0;
	fin>>p;
	for(int j=1;j<=1000000000;j++){
		k=0;
		for(int i=5;j/i>=1;i*=5)
			k+=j/i;
		if(k==p)
			cout<<j, j=1000000001;
		if(k>p)
			fout<<"-1", j=1000000001;
	}
}