|
|
вернуться в форумwhat is the problem in my code?? #include<iostream> using namespace std; int x=1; int recursive(int n) { if(n==0) return 0; if(n==1) return n; if((n%2)==0) recursive(n/2); else if(n>2 ) { if(n%2) { recursive(n/2); return 1+recursive((n/2)+1); }
} return x; } int maxi(int input) { int temp,result=0; for(int i=0;i<=input;i++) { temp=recursive(i); if(result<temp) { result=temp; } } return result; } int main(void) { int result,input=-1; while(1) { cin>>input; if(input==0) break; result=maxi(input); cout<<result<<endl; } return 0; } Re: what is the problem in my code?? It's very bad Re: what is the problem in my code?? you can't do brute thing ... |
|
|