Cod sursa(job #824209)
Utilizator | FMI Badila Victor Ioan Victeur1 | Data | 26 noiembrie 2012 00:06:23 |
---|---|---|---|
Problema | Factorial | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.82 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main(){
ifstream f("fact.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){
P--;
k=k/10;
}
while(k%10==5){
P--;
k=k/5;
}
}
}
if(P<0) nr=-1;
ofstream g("fact.out");
g<<nr;
g.close();
return 0;
}