Cod sursa(job #1327001)

Utilizator alexandrastaniselStanisel Alexandra alexandrastanisel Data 26 ianuarie 2015 12:02:02
Problema Factorial Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.43 kb
#include <iostream>
#include <fstream>
#include <cstdio>
using namespace std;
ofstream g("fact.out");
int k, i, a, n, P;
int main()
{
    freopen("fact.in", "r", stdin);
    scanf("%d", &P);
    if(P!=0){
    while(i<P)
    {
        n+=5;
        a=n;
        k=0;
        while(a%5==0)
        {
            k++;
            a/=5;
        }
        i+=k;
    }
    }
    else n=1;
    g<<n;
    return 0;
}