Metal Steak

Hard to eat

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  0 Posts :: 79 Stories :: 0 Comments :: 0 Trackbacks

公告

aaaaaaaaaaaa

常用链接

留言簿(1)

我参与的团队

搜索

  •  

最新评论

#include <iostream>
using namespace std;

int
ans[
1001], a[1001], cnt, sigmaw;
const int
weight[
7= { 012351020 };

void
__read__()
{
    
forint i = 1; i <= 6; i++ )
    {
        
int x;
        cin 
>> x;
        
forint j = 1; j <= x; j++ )
        {
            a[
++cnt] = weight[i];
            sigmaw 
+= weight[i];
        }
    }
}

void
__init__()
{
    
forint i = 1; i <= cnt; i++ )
        ans[a[i]] 
= true;
}

void
__dp__()
{
    ans[
0= true;
    
forint i = 1; i <= cnt; i++ )
        
forint j = sigmaw; j >= a[i]; j-- )
            ans[j] 
= ans[j - a[i]] || ans[j];
}

void
__outp__()
{
    
int count = 0;
    
forint i = 1; i <= sigmaw; i++ )
        
if( ans[i] )
            count
++;
    cout 
<< "Total=" << count << endl;
}

int
main()
{
    __read__();
    __dp__();
    __outp__();

    
return 0;
}

posted on 2009-09-15 21:02 mad4alcohol 阅读(221) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航:   博客园   博客园最新博文   博问   管理