当前位置: 首页 > wzjs >正文

网站建设工程师待遇小蝌蚪幸福宝入口导航

网站建设工程师待遇,小蝌蚪幸福宝入口导航,红河网站建设设计,wordpress自动保存编辑器图片题目 492. 矩阵取数游戏 思路 不难发现, 每一行之间是独立的, 因此可以求出每一行的最大值, 然后行与行之间最大值相加, 就是总的最大值 对于行内来说, 每次可以选取左边或者右边, 可以使用区间 d p dp dp求解, 时间复杂度 O ( n 3 ) O(n ^ 3) O(n3), 因为列的最大值是 80 …

题目

492. 矩阵取数游戏
在这里插入图片描述

思路

不难发现, 每一行之间是独立的, 因此可以求出每一行的最大值, 然后行与行之间最大值相加, 就是总的最大值
对于行内来说, 每次可以选取左边或者右边, 可以使用区间 d p dp dp求解, 时间复杂度 O ( n 3 ) O(n ^ 3) O(n3), 因为列的最大值是 80 80 80, 会超过 l o n g l o n g long \, long longlong的最大范围, 可以使用__int128, 或者高精度加法处理结果

*被坑了, 计算 2 k 2 ^ k 2k时也要转为 i 128 i128 i128

#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>using namespace std;typedef __int128 i128;
const int N = 90;int n, m;
int w[N][N];
i128 f[N][N];ostream &operator<< (ostream &out, i128 val) {if (val == 0) {out << 0;return out;}vector<int> vec;while (val) vec.push_back(val % 10), val /= 10;while (!vec.empty()) out << vec.back(), vec.pop_back();return out;
}i128 solve(int w[]) {memset(f, 0, sizeof f);for (int len = 1; len <= m; ++len) {for (int i = 1; i + len - 1 <= m; ++i) {int j = i + len - 1;int cnt = m - j + i;if (len == 1) {f[i][j] = (i128) w[i] * (1 << cnt);continue;}f[i][j] = max(f[i + 1][j] + (i128) w[i] * (1 << cnt), f[i][j - 1] + (i128) w[j] * (1 << cnt));}}return f[1][m];
}int main() {ios::sync_with_stdio(false);cin.tie(0), cout.tie(0);cin >> n >> m;for (int i = 1; i <= n; ++i) {for (int j = 1; j <= m; ++j) {cin >> w[i][j];}}i128 res = 0;for (int i = 1; i <= n; ++i) res += solve(w[i]);cout << res << "\n";return 0;
}

A C AC AC代码

#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>using namespace std;typedef __int128 i128;
const int N = 90;int n, m;
int w[N][N];
i128 f[N][N];ostream &operator<< (ostream &out, i128 val) {if (val == 0) {out << 0;return out;}vector<int> vec;while (val) vec.push_back(val % 10), val /= 10;while (!vec.empty()) out << vec.back(), vec.pop_back();return out;
}i128 solve(int w[]) {memset(f, 0, sizeof f);for (int len = 1; len <= m; ++len) {for (int i = 1; i + len - 1 <= m; ++i) {int j = i + len - 1;int cnt = m - j + i;if (len == 1) {f[i][j] = (i128) w[i] * ((i128) 1 << cnt);continue;}f[i][j] = max(f[i + 1][j] + (i128) w[i] * ((i128) 1 << cnt), f[i][j - 1] + (i128) w[j] * ((i128) 1 << cnt));}}return f[1][m];
}int main() {ios::sync_with_stdio(false);cin.tie(0), cout.tie(0);cin >> n >> m;for (int i = 1; i <= n; ++i) {for (int j = 1; j <= m; ++j) {cin >> w[i][j];}}i128 res = 0;for (int i = 1; i <= n; ++i) res += solve(w[i]);cout << res << "\n";return 0;
}
http://www.dtcms.com/wzjs/579150.html

相关文章:

  • 天津制作企业网站的ui设计师简历
  • 正规网站开发需要哪些技术企业装修展厅公司
  • 网站开发的形式是discuz开放平台
  • 山西省建设监理协会网站wordpress的运用
  • 免费企业网站管理系统那个网站做外贸
  • 自己做网站要多久wordpress开发移动端
  • 惠州网站建设电话上海网站建设微信开发
  • 网站从哪些方面来做设计类专业需要艺考吗
  • 中国建设电工网站深圳设计公司排深圳市广告公司名
  • 服装商城网站建设价格桂林昨晚发生的新闻
  • 图标网站导航制作怎么做wordpress ip改域名
  • 奥运会网站制作上海著名网站设计公司
  • 用微信小程序怎么做网站网络架构相关文献
  • js做各类图表网站大数据营销策略有哪些
  • 怎样让百度搜索到自己的网站宾爵手表官方网站
  • 做网站的ui深圳网络推广案例
  • 如何制作家具网站外国网站后台
  • 电商网站开发平台一跨境电商软件erp排名
  • 江西建设工程质量管理网站公司用wordpress建站用花钱
  • 怀化本地网站html5企业网站案例
  • 辅助wordpress 页面编辑器网站版面布局对seo
  • 重庆外贸网站建设关注公众号一单一结兼职app
  • 怎样黑网站东莞手机网站制作
  • 企业网站建设规划的基本原则有哪些汉中微信网站建设推广
  • 网站开发亿码酷技术怎么做推广赚钱
  • 长沙招聘网站有哪些wordpress视频外链
  • 没有网站怎么做百度竞价广州专做优化的科技公司
  • 大学生网站开发项目计划书范文昆明小程序开发制作公司
  • 长沙企业网站模板大学国际化网站建设
  • 晋城网站seo千图网素材解析网站开发