Cod sursa(job #350164)

Utilizator CehashishChis Ovidiu Cehashish Data 22 septembrie 2009 22:16:51
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include<iostream>
#include<fstream>
using namespace std;

int main()
{
ifstream f;f.open("fact.in");
ofstream g;g.open("fact.out");
unsigned long int n,aux,nr,a,b;
f>>n;
while(n!=0)
{
f>>nr;
a=0;
b=0;
while(b<nr)
 {a=a+5;
  aux=a;
  while(aux!=0)
   {if(aux%5==0)
     b++;
    aux=aux/5;}
  }
if((n==1)&&(b==nr)) g<<a<<endl;
 else g<<"-1";<<endl;
if((n!=1)&&(b==nr)) g<<a<<endl;
 else g<<"-1";<<endl;
n--;
}
g.close();
f.close();
return 0;
}