Cod sursa(job #429477)
| Utilizator | Data | 30 martie 2010 10:47:08 | |
|---|---|---|---|
| Problema | Factorial | Scor | 5 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <fstream>
using namespace std;
long long puteri[26], n;
int p;
void citire ()
{
ifstream in("fact.in");
in >> p;
}
void constructie ()
{
puteri[1] = 25;
for (int i = 2; i <= 25; i++)
puteri[i] = puteri[i-1] * 5;
}
int main ()
{
citire ();
constructie ();
n = 5 * p;
int i = 1;
while (puteri[i] <= n)
{
int x = puteri[i];
int z = 2;
while (x < n)
{
n -= 5;
x *= z;
z ++;
}
i++;
}
ofstream out("fact.out");
out << n;
return 0;
}
