Pagini recente » Cod sursa (job #438875) | Cod sursa (job #2564407) | Cod sursa (job #832707) | Cod sursa (job #2067417) | Cod sursa (job #707741)
Cod sursa(job #707741)
#include <fstream>
#include <math.h>
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 long small_fact(long x, long y) {
long m = (x + y)/2;
if ((log10(m) + 1) > p)
return small_fact(x,m);
else if ((log10(m) + 1) < p)
return small_fact(m,y);
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;
}