Cod sursa(job #3260312)

Utilizator Octavian09Dore Octaviam Octavian09 Data 1 decembrie 2024 16:14:42
Problema Factorial Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.59 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream f("fact.in");
ofstream g("fact.out");

long long putere(int n){
    long long s=0,p=5;
    while(p <= n){
        s += n / p, p *= 5;
    }
    return s;
}

int main()
{
    long long P;
    int p;
    bool stop = false;
    f >> P;
    long long i=1;
    while(stop == false){
        p=putere(i*5);
        if(p==P){
            g << i*5;
            stop = true;
        }
        else if(p > P){
            g << -1;
            stop = true;
        }
        i++;
    }

    return 0;
}