Cod sursa(job #1188809)

Utilizator andrey1440Tuiu Andrei andrey1440 Data 20 mai 2014 16:57:56
Problema Factorial Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <iostream>
#include <fstream>
using namespace std;
int n,i,k,m,j,p;
int main()
{
    ifstream f("fact.in");
    ofstream g("fact.out");
    f>>n;
    m=1;j=1;
    if(n==0)g<<"1";
    if(n==5 || (n-5)%6==0)g<<"-1";
    else{
    while(p<n)
    {
        while(m%10==0)
        {
            p++;m=m/10;
        }
        m=m%10*j;
        j++;
        if(p==n){j=j-2;g<<j;}
        if(p>n) g<<"-1";
    }
    }
    return 0;
}