CodeForces 687C The Values You Can Make
来源:互联网 发布:java打包war步骤 编辑:程序博客网 时间:2024/06/04 18:54
dp[i][j]表示i可以构成j则为true:
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <cmath>using namespace std;typedef long long LL;const int maxn = 1000 + 7;int n, k;bool dp[maxn][maxn];int main() {scanf("%d%d", &n, &k);memset(dp, 0, sizeof(dp));dp[0][0] = true;while(n--) {int t; scanf("%d", &t);for(int i = k; i >= 0; --i) {for(int j = 0; j <= k; ++j) {if(dp[i][j]) dp[i+t][j] = dp[i+t][j+t] = true;}}}int j = 0, a[maxn];for(int i = 0; i <= k; ++i) if(dp[k][i]) a[j++] = i;printf("%d\n", j);for(int i = 0; i < j; ++i) {if(!i) printf("%d", a[i]);else printf(" %d", a[i]);}printf("\n");}
0 0
- Codeforces 687C The Values You Can Make(背包)
- Codeforces-687C The Values You Can Make
- CodeForces 687C The Values You Can Make
- CodeForces 687C The Values You Can Make
- CodeForces 687C The Values You Can Make
- Codeforces 687C The Values You Can Make DP
- 687C: The values you can make
- Codeforces 689 C The Values You Can Make(dp)
- The Values You Can Make CodeForces
- [DP] Codeforces 687C #360 (Div. 1) C. The Values You Can Make
- 7_6_M题 The Values You Can Make题解[Codeforces 687C](DP)
- CodeForces 687C - The Values You Can Make(01背包dp)
- codeforces 687C - The Values You Can Make(背包+滚动数组)
- The Values You Can Make
- The Values You Can Make
- codeforces 688 E. The Values You Can Make
- 【43.75%】【codeforces 688E】The Values You Can Make
- Codeforces 688E The Values You Can Make【Dp】
- setFocusable , setEnabled ,setClickable 区别
- 第15周 啊哈算法 排序算法
- 显试调用DLL------GetProcAddress的使用
- 腾讯云cos对象存储服务文件上传api就是一个大坑
- Android ToolBar修改返回按钮图标
- CodeForces 687C The Values You Can Make
- Maven学习笔记——常用插件配置详解
- 物理学基石 —— 麦克斯韦方程组
- 二,iOS应用架构谈 view层的组织和调用方案
- excel 数据读取(未在本地计算机上注册“Microsoft.Jet.OLEDB.4.0”提供程序)
- springmvc中方法之间的跳转。
- java图片处理,裁剪,合图,等比例缩放
- ugui Slider使用(固定大小图片)
- ElasticSearch安装和配置head、bigdesk、IkAnalyzer