巢穴

about:blank

P2586

还是贪心..
枚举5个月所有的可能..

#include <iostream>
using namespace std;

long s,d;
int main()
{
    
    
long ans;
    
while(cin>>s>>d)
    
{
     
     
if (s*4-d<0)
     
{
      ans
=s*8-2*d+2*s;
     }

     
else
     
{
         
if (s*3-2*d<0)
         
{
          ans
=s*6-4*d+2*s;
         }

         
else
         
{
          
if (s*2-3*d<0)
          
{
           ans
=s*4-6*d+2*s;
          }

          
else
          
{
              
if (s-4*d<0)
              
{
               ans
=s*2-8*d+s-d;
              }

              
else
              
{
               ans
=-12*d;
              }
           
          }

         }

         
     }

     
if (ans<=0) cout<<"Deficit"<<endl;
     
else
         cout
<<ans<<endl;
    }

    
return 0;
}

posted on 2009-10-02 22:48 Vincent 阅读(68) 评论(0)  编辑 收藏 引用 所属分类: 数据结构与算法


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