Cod sursa(job #2515944)

Utilizator RazvanLazar2004Lazar Razvan Gabriel RazvanLazar2004 Data 29 decembrie 2019 20:34:31
Problema Factorial Scor 35
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.39 kb
#include<fstream>
using namespace std;
int main(){
    ifstream in("fact.in");
    ofstream out{"fact.out"};
    long long int n,m=0,t=1;
    in>>n;
    if(n!=0){
        t--;
    }
    while(m<n){
        t+=5;
        long long int c=t;
        while(c%5==0){
            m++;
            c/=5;
        }
    }
    if(m-n){
        out<<"-1";
    }else{
        out<<t;
    }
}