Cod sursa(job #826698)

Utilizator andrey1440Tuiu Andrei andrey1440 Data 1 decembrie 2012 08:38:11
Problema Factorial Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include <iostream>
#include <fstream>
using namespace std;
int a,b,N,p;
long pr;
int main()
{
    ifstream f("fact.in");
    ofstream g("fact.out");
    f>>p;
    N=1;
    pr=1;
    a=1;
    b=1;
    while(p>=1)
    {
        b=b*10;p--;
    }
    while(a==1)
    {
    pr=pr*N;
     if(pr%(b*10)==0) {a=0;g<<"-1";}
    else {if(pr%b==0) {a=0;g<<N<<endl;}}

    pr=pr%(b*100);
    N++;
    }
    g.close();
    f.close();
    return 0;
}