|
|
back to boardCan't find compile error Posted by Sid 6 Apr 2005 22:39 This program compiles on my PC but I got compile error... Please help me.. #include <iostream.h> #include <math.h> unsigned long fackt(int t) { unsigned long tot=1; int h; for (h=1;h<=t;h++) tot*=h; return tot; } unsigned long f(int t, int t2) { if ((t<t2)||(t<=0)) return 0; double o=1; int p; for(p=t-t2+1;p<=t;p++) o*=p; o/=fackt(t2); return (unsigned long)o; } unsigned long getres(unsigned long val,int k2,bool bb,int b) { if (k2==0) return 0; unsigned long res=0; int kk=(int)(log(val)/log(b)+1); bool b2=false; if (val-pow(b,kk-1)<pow(b,kk-2)) b2=true; res+=f(kk-1,k2); if (k2>1)res+=getres(unsigned long(val-pow(b,kk-1)),k2-1,b2,b); if (bb) { int i=0; unsigned long buf=0; for (i=0;i<k2;i++) buf+=unsigned long(pow(b,kk-i-1)); if ((val>=buf)&&(buf>0)) res++; } return res; } int main() {
unsigned long x,y; int k,b; cin>>x>>y>>k>>b;
unsigned long l,u,total=0; l=getres(y,k,true,b); u=getres(x-1,k,true,b);
cout<<l-u;
return 0; } Re: Can't find compile error Use logl instead of log. You can use with confidence the judge compilation error catcher. Re: Can't find compile error Posted by Sid 7 Apr 2005 10:19 Thanks... It's very strange but i cant imagine test #3 where i got time limit Edited by author 07.04.2005 10:29 |
|
|