Cod sursa(job #1658404)

Utilizator LaurIleIle Laurentiu Daniel LaurIle Data 21 martie 2016 14:43:00
Problema Factorial Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int v[5],s[5];
 long long n=1;
int main()
{    int i=0,P,x;
     f>>P;
    v[5]=P;
    if (P==0) g<<1;
    else
    while (i!=1)
    {
        i+=5;
        x=i;
        while(x!=0)
        {
        if (x%5==0)
        {
        s[5]+=1; if(s[5]==v[5]) {n=x; x=0; i=1;} }
        x=x/5;

        }

    }

    g<<n;

    return 0;
}