Cod sursa(job #2622336)

Utilizator andreea.bucurBucur Andreea andreea.bucur Data 31 mai 2020 22:53:47
Problema Factorial Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.53 kb
#include<iostream>
#include<fstream>
using namespace std;
ifstream f("fact.in");
ofstream g("fact.out");
int main()
{
    int long long p,n,aux=1,ok=0,gasit=0;
    f>>p;
    for(int i=1;i<=p;i++)
        aux*=10;
    cout<<aux<<endl;

    n=1;
    int x=2;
    while(ok==0)
    {
        if(n%aux==0 && n%(aux*10)!=0)
        {
            ok=1;
        }
        else
            {n=n*x;
            x++;
            }
        if(n<0) { gasit=1;break;}
    }

    if(gasit==1) g<<"-1";
       else  g<<x-1;



}