当前位置:网站首页>Zhinai buys melons (DP backpack)
Zhinai buys melons (DP backpack)
2022-07-26 01:48:00 【to cling】
2022 Niuke winter vacation algorithm basic training camp 3
Version One
The question

State transition equation :
d p [ i ] [ j ] = d p [ i − 1 ] [ j − w [ i ] ] + d p [ i − 1 ] [ j − w [ i ] / 2 ] dp[i][j] = dp[i - 1][j - w[i]] + dp[i - 1][j - w[i]/2] dp[i][j]=dp[i−1][j−w[i]]+dp[i−1][j−w[i]/2]
CODE
const int N = 2e3 + 7;
ll dp[N], a[N];
int main()
{
IOS;
int n, m; cin >> n >> m;
for (int i = 1; i <= n; i++)
cin >> a[i];
dp[0] = 1;
for (int i = 1; i <= n; i++)
{
for (int j = m; j >= a[i]/ 2; j--)
{
if (j >= a[i])
dp[j] = (dp[j] + dp[j - a[i]]) % mod;
dp[j] = (dp[j] + dp[j - a[i] / 2]) % mod;
}
}
for (int i = 1; i <= m; i++)
cout << dp[i] << " ";
return 0;
}
Version Two
The question

Ideas
边栏推荐
- Ideal Path(UVA - 1599)
- y77.第四章 Prometheus大厂监控体系及实战 -- prometheus的服务发现机制(八)
- 大佬们, flinksql datahub源表,源表有字段 timestamp 16位, 写入Ora
- Understand Linglong platform unified access service from simple to deep Monet
- Software group verification
- Leetcode/ numbers that appear only once
- 劳驾问一下各位老师 oracle 到pg cdc oracle 那边字段大写 pg 这边小写 同
- My Mysql to MySQL data table synchronization, only the code written in the first order will take effect, and the rest will not take effect. This may be
- npm ERR! code ETIMEDOUTnpm ERR! syscall connectnpm ERR! errno ETIMEDOUTnpm ERR! network request t
- 图像批处理高斯滤波降噪+峰值信噪比计算
猜你喜欢

餐饮连锁门店重塑增长背后的数字化转型

Cross Site Request Forgery (CSRF): impact, examples, and Prevention

SVN版本控制分支、合并功能使用

推荐系统-协同过滤在Spark中的实现

IDEA如何快速删除最近打开的项目

怎么使用宝塔面板把node全栈项目部署到服务器上

Digital transformation behind the reshaping growth of catering chain stores

言语理解-片段阅读的结构剖析练习

Image batch processing Gaussian filter noise reduction + peak signal-to-noise ratio calculation

推荐⼀款超好⽤的UI⾃动化⼯具: UiAutomator2!
随机推荐
What is a test case? How to design?
Shell summary (1)
"Weilai Cup" 2022 Niuke summer multi school training camp 2 i.[let fat tension] matrix multiplication j.[link with arithmetic progression] linear regression
Study notes: original code, inverse code, complement code
[combinational logic circuit] - encoder
Easyrecovery15 data recovery software with high recovery rate and high download volume
flutter 下 grpc list没有Setter 方法 ,如何使用相关属性
When everything can be metauniverse, the development of metauniverse seems to have entered a new stage of development
Typora expiration solution, what if typora can't open
I want to know how much the Commission is for opening an account. Is it safe to open an account on your mobile phone
【Verilog数字系统设计(夏宇闻)3-----Verilog语法的基本概念1】
My Mysql to MySQL data table synchronization, only the code written in the first order will take effect, and the rest will not take effect. This may be
图像批处理高斯滤波降噪+峰值信噪比计算
Dijkstra find the shortest path
The best way to practice Animation: cover transition
npm ERR! code ETIMEDOUTnpm ERR! syscall connectnpm ERR! errno ETIMEDOUTnpm ERR! network request t
"Wei Lai Cup" 2022 Niuke summer multi school training camp 2 personal problem sets
Record a failure caused by a custom redis distributed lock
There is no setter method in grpc list under flutter. How to use related attributes
B - Krypton Factor(dfs+回溯法)