Cod sursa(job #1295352)

Utilizator bence21Bako Bence bence21 Data 19 decembrie 2014 12:13:37
Problema Factorial Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.39 kb
#include<fstream>
#include<iostream>
using namespace std;
int main()
{
    ifstream f("fact.in");
    ofstream g("fact.out");
    int n,y,x,a;
    f>>n;
    if(n==0)
        g<<1;
    else
    {
        x=5*n;
        y=(x-5)/25;
        x-=5*y;
        y=x/5+x/25+x/125;
        if(y==n)
            g<<x;
        else g<<-1;
    }
    f.close();
    g.close();
    return 0;
}