misschuer

常用链接

统计

积分与排名

百事通

最新评论

Change the ball

#include < iostream >
using namespace std;

int temp , a1 , b1 , c1;

int h;

int dfs(int a , int b , int c)
{
       
if (a == b || b == c)
    
{
        printf (
"%d\n" , b + h);
        
        
return 1;
    }
    
    
else
    
{
        
if( a > b || a > c)
        
{

          
if(a > b)
            
             temp 
= a , a = b , b = temp;
        
             
if(a > c)
            
            temp 
= a , a = c , c = temp;
        
          
if(b > c)
            
            temp 
= b , b = c , c = temp;
          
        }


         
if(a1 == a && c1 == c)

              
return 0;

        
else
        
{
           a1 
= a , b1 = b , c1 = c; 

             h 
++;

              dfs(a 
+ 2 , b - 1 , c - 1);
        }


    }

}


int main()
{
    
    
int a , b , c;
    
    
while (scanf ("%d %d %d" , &a , &b , &c) != EOF)
    
{
        
        
if(a > b)
            
            temp 
= a , a = b , b = temp;
        
        
if(a > c)
            
            temp 
= a , a = c , c = temp;
        
        
if(b > c)
            
            temp 
= b , b = c , c = temp;
        h 
= 0;

        
if(!dfs(a,b,c))
            
            printf(
"):\n");
    }

    
    
return 23;
}

posted on 2009-04-18 10:47 此最相思 阅读(130) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理