Cod sursa(job #672930)

Utilizator tanduraDomnita Dan tandura Data 3 februarie 2012 14:34:22
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.53 kb
#include<iostream>
#include<fstream>
#include<time.h>
using namespace std;

int p,i,n,n5,aux,j,k;

int main()
{int t1,t2;
t1=clock();
ifstream g("fact.in");
g>>p;
i=1; j=25; n=25; k=0;
while(n5<p)
{aux=i*5; 
 if(aux%5==0)
     {n5++;
      if(aux==j)
	    {n5++;
	     j+=25;
           n++;}
      if(aux==n*5)
        {n*=5; k++;
         n5+=k;}
     }
i++;}
ofstream t("fact.out");
if(i-1==0)
	t<<1;
else
    t<<aux;
t.close();
g.close();
t2=clock();
cout<<(double)(t2-t1)/CLOCKS_PER_SEC;
return 0;}