Cod sursa(job #1480493)

Utilizator dareare14Daria Petca dareare14 Data 2 septembrie 2015 17:51:14
Problema Factorial Scor 15
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.66 kb
#include <iostream>
#include <fstream>
using namespace std;

ifstream F("fact.in");
ofstream G("fact.out");

void var1()
{
    int m,n,a,b;
    m=n;
    b=0;
    while (n!=0)
    {
        b++;
        n /= 5; // n = n / 5
    }
    n = m;
    int pw = 1, tot = 0;
    for (int i=1;i<=b;++i)
    {
        pw *= 5;
        tot = tot + n / pw;
    }
    cout<<tot<<'\n';
}

int zerouri(int n)
{
    int tot = 0, pw = 5;
    while ( pw <= n )
    {
        tot += n/pw;
        pw *= 5;
    }
    return tot;
}

int n;

int main()
{
    F>>n;
    int a = 1;
    while ( zerouri(a) < n )
        ++a;
    G<<a<<'\n';
    return 0;
}