Cod sursa(job #600901)
Utilizator | Data | 4 iulie 2011 00:55:15 | |
---|---|---|---|
Problema | Factorial | Scor | 15 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.37 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ifstream in ("fact.in");
ofstream out ("fact.out");
int n, i, count;
in >> n;
count = 0;
for (i = 1;count < n; i++)
{
if (i % 5 != 0)
count++;
else
count += i/5 + 1;
if (count == n)
{
out << i * 5;
break;
}
}
if (n == 0)
out << 1;
else
if (count > n)
out << -1;
return 0;
}