Mai intai trebuie sa te autentifici.
Cod sursa(job #600910)
Utilizator | Data | 4 iulie 2011 03:37:36 | |
---|---|---|---|
Problema | Factorial | Scor | 15 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ifstream in ("fact.in");
ofstream out ("fact.out");
int n, i, count ,temp;
in >> n;
count = 0;
int fives = 0;
int pivot = 1;
for (i = 1; count < n; i++)
{
count ++;
if (i % pivot == 0 )
count += fives;
if (i == pivot * 5)
{
pivot = i;
fives ++;
count ++;
}
if (count == n)
{
out << i*5;
break;
}
}
if (n == 0)
out << 1;
else
if (count > n)
out << -1;
return 0;
}