ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1079. Maximum

what is the problem in my code??
Posted by Md.Forhad Hossain 26 Jan 2011 14:12
#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??
Posted by Randy Mujica 22 Aug 2011 04:48
It's very bad
Re: what is the problem in my code??
Posted by staticor 25 Jun 2013 07:46
you can't do brute thing ...