Cod sursa(job #823787)
Utilizator | FMI Badila Victor Ioan Victeur1 | Data | 25 noiembrie 2012 17:03:07 |
---|---|---|---|
Problema | Factorial | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.73 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main(){
ifstream f("factorial.in");
int P, nr=1;
f>>P;
f.close();
while(P>0){
nr++;
if(nr%10==5){
int k=nr;
while(k%10==5){
P--;
k=k/5;
}
}
if(nr%10==0){
int k=nr;
while(k%10==0 && k!=0){
P--;
k=k/10;
}
}
}
if(P<0) nr=-1;
ofstream g("factorial.out");
g<<nr;
g.close();
return 0;
}