Cod sursa(job #540537)
Utilizator | FMI - Dan Moldovan MDan | Data | 24 februarie 2011 00:36:38 |
---|---|---|---|
Problema | Factorial | Scor | 70 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.79 kb |
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include<fstream>
#include<cstdio>
using namespace std;
int main(){
ifstream f ("fact.in");
ofstream g ("fact.out");
long n, i, j;
long coefSolutie;
long solutie;
f >> n;
i = 0;
while (n > 0){
i++;
j = i;
n--;
while (true){
if (j == 0)
break;
if (j%5 == 0){
n--;
j /=5;
}
else
break;
}
}
if (n == 0)
solutie = 5 * i;
else
solutie = -1;
g << solutie;
f.close();
g.close();
}