|
|
вернуться в форумwhat is the wrong in this solution to the 1079 problem. #include <stdio.h> #include <time.h> //#include <windows.h> // GetTickCount() int fun(int n); int main() { int n,max,t,x; long te=0, ts=0; printf("\n Enter the Number..\n"); scanf("%d",&n); x=n; max=0; // ts = GetTickCount(); if(n%2==0) n=n-1; while(n>=0) { if((t=fun(n))>max) max=t; n=n-2;
}
printf("\n %d %d \n",x,max); // te = GetTickCount(); // printf("\n ts=%ld \n",te); //printf("%d ms\n", te - ts); // getch();
} int fun(int n) { if(n==0)return 0; else if(n==1)return 1; else if(n%2==0)return(fun(n/2)); else if(n%2==1)return(fun((n-1)/2)+fun((n-1)/2+1));
return 0; } Re: what is the wrong in this solution to the 1079 problem. |
|
|