Cod sursa(job #3250540)

Utilizator carol14Georgescu Razvan-Carol carol14 Data 21 octombrie 2024 19:42:44
Problema Factorial Scor 75
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.47 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fact.in");
ofstream fout("fact.out");
int p,i,x,y;
long long n,cnt;
int main()
{
    fin>>p;
    //cin>>p;
    for(n=5;x<p;n+=5){
    y=n;
    while(y%5==0){
        x++;
        y/=5;
    }
    //cout<<x<<" "<<cnt<<endl;
}
    if(p==0){
        fout<<0;
    }
    else if(x==p){
        fout<<n-5;
        //cout<<n-5;
    }else{
        fout<<-1;
        //cout<<-1;
    }
}