当前位置:网站首页>[dynamic programming] p1018 linear DP: maximum product
[dynamic programming] p1018 linear DP: maximum product
2022-06-28 21:52:00 【muse_ age】


Code :
This problem needs high precision , Only through 20 branch
#include<iostream>
#include<string>
using namespace std;
int dp[41][6];
int a[41];
int to_int(int i,int j){
int res=0;
for(int k=i;k<=j;k++){
res=res*10+a[k];
}
return res;
}
int main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
scanf("%1d",&a[i]);// Take only one number at a time
}
for(int i=1;i<=n;i++){
dp[i][0]=to_int(1,i);
}
for(int i=1;i<=n;i++){
for(int k=1;k<=m;k++){
for(int j=1;j<i;j++){
if(i<=k)dp[i][k]=0;
else
dp[i][k]=max(dp[i][k],dp[j][k-1]*to_int(j+1,i));
}
}
}
cout<<dp[n][m];
}
边栏推荐
- 为什么要使用 Rust 语言?
- Security dilemma of NFT liquidity agreement - Analysis of the hacked event of NFT loan agreement xcarnival
- Study on luminiprobe non fluorescent azide -- 3-azido propanol
- 华为云的AI深潜之旅
- Recommend two high-quality Wallpaper software
- LeetCode116. 填充每个节点的下一个右侧节点指针
- Proficient in data analysis, double the income? What is the strongest competitiveness
- Is it safe to open an account for stocks on mobile phones in 2022? Who can I ask?
- The further application of Li Kou tree
- QT 一个控件的坐标怎么相对固定显示在另一个控件上(坐标系)
猜你喜欢

Interface use case design

CVPR 2022 𞓜 a creative and aesthetic text generation method! Support any input

PHP uses stack to solve maze problem

How do independent site sellers efficiently manage complex Facebook pages?
![Sword finger offer:[day 2 linked list (simple)] --- > print the linked list from end to end](/img/d6/824985b74b27a1bee456c2cebbac26.jpg)
Sword finger offer:[day 2 linked list (simple)] --- > print the linked list from end to end

直播预告|SQL也能玩转工业级机器学习?MLOps meetup V3带你一探究竟!

Figure neural network can also be used as CV backbone model. Huawei Noah Vig architecture is comparable to CNN and transformer

Construction and application of urban brain knowledge map

Security dilemma of NFT liquidity agreement - Analysis of the hacked event of NFT loan agreement xcarnival

16 `bs object Node name Div. attribute contents ` children descendants get child nodes and descendants
随机推荐
Smarca2 antibody study: abnova smarca2 monoclonal antibody protocol
Is the rapid SSL wildcard certificate genuine in 1981
LeetCode122. The best time to buy and sell stocks II
LeetCode986. 区间列表的交集
【读书会第13期】视频文件的封装格式
ID access card copied to mobile phone_ How to turn a mobile phone into an access card mobile NFC copy access card graphic tutorial
Ehcache configuration data, convenient for self checking
Leetcode: merge two ordered linked lists_ twenty-one
AI deep dive of Huawei cloud
2022年股票在手机上开户安全吗?找谁可以办理?
QStringLiteral(str)
Bitbucket 使用 SSH 拉取仓库失败的问题
pyechart绘制多条y轴折线图
External parameter calibration method for 16 line mechanical radar and monocular camera based on solid state lidar
接口测试流程
LeetCode1114. 按序打印
Which is the most reliable and safe for a securities company to open an account
河狸生存记:90后女博士与AI开发者们
Application of the purple book p113map of ananagrams (uva156)
Deep interpretation of WiFi security vulnerability krack