Cod sursa(job #970682)
Utilizator | Gabriel Badea gabriel.badea | Data | 7 iulie 2013 15:59:04 |
---|---|---|---|
Problema | Factorial | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.63 kb |
#include<iostream>
#include<stdio.h>
#define Nmax 100000000
using namespace std;
int main()
{
int i, d, N, x, P, nr2, nr5;
nr2 = nr5 = 0;
freopen("fact.in","r", stdin);
freopen("fact.out", "w", stdout);
cin >> P;
x = 1;
while(x <= Nmax)
{
N = x;
while(N % 2 == 0)
{
N /= 2;
nr2++;
}
while(N % 5 == 0)
{
N /= 5;
nr5++;
}
if(min(nr2, nr5) == P)
{
cout << x;
return 0;
}
x++;
}
cout << '1';
return 0;
}