Cod sursa(job #1159254)
| Utilizator | Data | 29 martie 2014 14:15:10 | |
|---|---|---|---|
| Problema | Factorial | Scor | 5 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.6 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int p, i, n;
void read()
{
fin >> p;
}
int result(int n)
{
int c = 0;
while(n != 1)
{
n = n / 5;
c += 1;
if(n < 10 && n > 5) break;
if(n < 5 && n > 1) break;
}
return c;
}
int main()
{
read();
i = 1;
while(1)
{
i += 1;
if(i % 5 == 0)
{
n += result(i);
}
if(n == p)
break;
}
fout << i;
return 0;
}
