Cod sursa(job #2452286)
| Utilizator | Data | 30 august 2019 12:33:14 | |
|---|---|---|---|
| Problema | Factorial | Scor | 25 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <iostream>
#include <fstream>
using namespace std;
int fact(int n){
int putere = 0;
while (n % 5 == 0){
putere++;
n = n / 5;
}
return putere;
}
int main() {
ifstream in;
ofstream out;
in.open("fact.in");
out.open("fact.out");
int p, n;
in >> p;
n = 1;
int nr_cifre = 0;
if (nr_cifre == p){
cout << n;
return 0;
}
while (nr_cifre != p) {
nr_cifre += fact(n);
if (nr_cifre == p){
out << n ;
return 0;
}
if(nr_cifre > p){
out << -1;
return 0;
}
n++;
}
}