Cod sursa(job #1748869)

Utilizator Rocamadour1497Alexandru Martiniuc Rocamadour1497 Data 27 august 2016 01:00:56
Problema Factorial Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
const long long M=1000000000;
ifstream f("fact.in");
ofstream g("fact.out");
int p,i=1,nr5=0;
int n5(long long p)
{
    int pow = 1, s = 0;
    while ( pow * 5 <= p)
    {
        pow *= 5;
        s += p/pow;

    }
    return s;

}
int vf(int i)
{
    while(nr5<p)
{
    i++;
    if(n5(i)==p) break;
}
return n5(i)==p ? i : -1 ;
}
int main()
{

f>>p;
g<<vf(i);
    return 0;
}