Cod sursa(job #1667809)
Utilizator | Data | 29 martie 2016 11:39:49 | |
---|---|---|---|
Problema | Factorial | Scor | 5 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.48 kb |
#include <fstream>
#include <math.h>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int p,k,n,x;
int verif5(int n){
if(n==0)
return 1;
int p=0;
while(n!=1)
if(n%5==0){
n=n/5;
p++;}
else return 1;
return p;}
int main(){
int i;
fin>>p;
if(p==0)
fout<<1;
while(p>0){
k=verif5(x);
x+=5*k;
p=p-k;}
fout<<x;
return 0;
}