Cod sursa(job #823791)

Utilizator Victeur1FMI Badila Victor Ioan Victeur1 Data 25 noiembrie 2012 17:04:03
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.72 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 && k!=0){
                     P--;
                     k=k/10;
                     }
                     }
            }
    
    if(P<0) nr=-1;    
    ofstream g("fact.out");
    g<<nr;
    g.close();    
    
    return 0;
    
    }