Cod sursa(job #672912)
| Utilizator | Data | 3 februarie 2012 14:01:43 | |
|---|---|---|---|
| Problema | Factorial | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.44 kb |
#include<iostream>
#include<fstream>
#include<time.h>
using namespace std;
int p,i,n,n5,aux,j;
int main()
{int t1,t2;
t1=clock();
ifstream g("fact.in");
g>>p;
i=1; j=25;
while(n5<p)
{aux=i*5;
if(aux%5==0)
{n5++;
if(aux==j)
{n5++;
j+=25;}
}
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;}
