Cod sursa(job #707739)

Utilizator RodicaElenaAndronache Rodica RodicaElena Data 5 martie 2012 22:46:35
Problema Factorial Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.7 kb
#include<fstream>

using namespace std;

 int p;
/*
int calc_fact(int x) {
    if (x <= 1) return 1;
    else
        return calc_fact(x - 1);
}

int nr_cifre(int x) {
    int nr = 0;
    while(x) {
             x /= 10;
             nr++;
    }
    return nr;
}*/

long small_fact(int x, int y) {
    long m = (x + y)/2;
    if ((log10(m) + 1) > p)
       return small_fact(x,m,p);
    else if ((log10(m) + 1) < p)
         return small_fact(m,y,p);
    else return -1;
    
}


int main(){
    
   
    
    fstream f("fact.in",ios::in);
    fstream g("fact.out",ios::out);
    
    f>>p;
    g<<small_fact(1,1000000000);
    
    f.close();
    g.close();
    return 0;
}