Cod sursa(job #824235)

Utilizator Victeur1FMI Badila Victor Ioan Victeur1 Data 26 noiembrie 2012 01:40:59
Problema Factorial Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.56 kb
#include <iostream>
#include <fstream>

using namespace std;



int main(){
    ifstream f("fact.in");
    int P, nr=0;
    f>>P;
    f.close();
                
    while(P>0){
            nr=nr+5;
            if(nr%5==0){
                 int k=nr;
                 while(k%5==0){
                     P--;
                     k=k/5;
                     }
                 }
            }
            
    if(nr==0) nr=1;
    if(P<0) nr=-1;    
    ofstream g("fact.out");
    g<<nr;
    g.close();    
    
    return 0;
    
    }