Cod sursa(job #970956)
| Utilizator | Data | 8 iulie 2013 06:51:51 | |
|---|---|---|---|
| Problema | Factorial | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.87 kb |
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
long long p,i,l,q,c,ok,j,y;
int h[100000000];
int main()
{
fin>>p; q=100; c=1;
if(p==0) fout<<1;
else
{
for(j=5;j<=100000000;j=j*5)
h[j]=++y;
while(ok==0)
{i=i+5;
if(i%10==0)
{
l++;
if(p==l)
{
fout<<i;
return 0;
}
}
else
{
l=l+h[i];
if(h[i]==0) l++;
if(p==l)
{
fout<<i;
return 0;
}
}
if(i%q==0)
{
l=l+c; q=q*10; c++;
if(p==l)
{
fout<<i;
return 0;
}
}
}
}
return 0;
}
