B. Polo the Penguin and Matrix:题目

思路:纯暴力
#include <bits/stdc++.h>
using namespace std;
// #define int long long
vector<int> a((int)6e5);
vector<int> b((int)6e5), c((int)6e5);
const int mod = 1e9 + 7;
int g[111][111];
signed main()
{int n, m, d;cin >> n >> m >> d;for (int i = 1; i <= n; i++){for (int j = 1; j <= m; j++){cin >> g[i][j];}}int sum = 0x3f3f3f3f;for (int i = 1; i <= 10000; i ++){int h = i;int ff = 1;int res = 0;for (int k = 1; k <= n; k++){for (int kk = 1; kk <= m; kk++){int cha = abs(g[k][kk] - h);if (cha % d == 0)res += cha / d;elseff = 0;}}if (ff)sum = min(sum, res);}if (sum == 0x3f3f3f3f)cout << -1 << endl;elsecout << sum << endl;
}

289B. Polo the Penguin and Matrix相关推荐

  1. Polo the Penguin and Matrix

    Little penguin Polo has an n × m matrix, consisting of integers. Let's index the matrix rows from 1 ...

  2. 【CodeForces - 289E 】Polo the Penguin and XOR operation (数学,异或,贪心)

    题干: Little penguin Polo likes permutations. But most of all he likes permutations of integers from 0 ...

  3. 【CodeForces - 289D】Polo the Penguin and Houses (带标号的无根树,Cayley定理,Prufer编码)

    题干: Little penguin Polo loves his home village. The village has n houses, indexed by integers from 1 ...

  4. 【CodeForces - 289C】Polo the Penguin and Strings (水题,字符串,思维构造,有坑)

    题干: Little penguin Polo adores strings. But most of all he adores strings of length n. One day he wa ...

  5. codechef Polo the Penguin and the Tree

    一般xor 的题目都是用trie解决. 那这道题是在树上的trie; 首先:从root==1,遍历树得到1到所有节点的xor 值. 然后对于每个点我们把其插入二进制树中. 对于每一个点查找其二进值异或 ...

  6. Codeforces Round #177 (Div. 1)C. Polo the Penguin and XOR operation【贪心】

    http://codeforces.com/contest/288/problem/C 按二进制位从大到小进行匹配 #include <cstdio> #include <cstri ...

  7. 【Codeforces】A2组刷题记录(50 / 50)完结

    目录 A1. Counterexample A2. Good Number A3. Dice Tower ★A4. Alyona and Numbers A5. Mountain Scenery rz ...

  8. Android 自定义View ——Matrix (矩阵)

    Matrix的作用: Matrix类包含一个3x3矩阵,用于转换坐标 Matrix (矩阵) 的原理很遗憾自己目前也是含糊的很,这里就不说了,记录自己在项目使用的方法, 这里就简单的记录下Matrix ...

  9. Codeforces 903F Clear The Matrix(状态压缩DP)

    题目链接 Clear The Matrix 题意 给定一个$4 * n$的矩形,里面的元素为$'.'$或$'*'$.现在有$4$种正方形可以覆盖掉$'*'$,正方形的边长分别为$1,2,3,4$. 求 ...

最新文章

  1. android 线程 wait notify
  2. 怎么一键备份服务器系统还原,电脑怎么一键还原
  3. PHP语言特性和各版本的差异
  4. android jar 加密
  5. 新春大吉,2017 Make .NET Great
  6. message:MCODE参数不存在,mobile类型mcode参数必需
  7. 计算机网络 第一章 计算机网络和因特网
  8. jQuery插件开发的准备
  9. 如何制作一款HTML5 RPG游戏引擎——第二篇,烟雨+飞雪效果
  10. spring cloud构建互联网分布式微服务云平台-高可用的服务注册中心
  11. java odbc timesten_TimesTen ODBC 链接库差异及相关命令行工具的使用注意事项
  12. Java输入输出流体系
  13. android 七彩进度条背景图片,Android编程实现自定义ProgressBar样式示例(背景色及一级、二级进度条颜色)...
  14. 6plus经常显示无服务器,苹果6plus屏幕失灵怎么办?如何解决?
  15. 分子动力学软件-VMD(win版)
  16. 北邮硕士、前百度工程师:能进大厂,就不用读研究生了!
  17. 学会这些快准狠的Word技巧,你也能成为Word高手
  18. VVC帧间预测(十)帧间帧内联合预测CIIP
  19. The Shawshank Redemption-6
  20. 模拟通讯录系统2.0

热门文章

  1. 通过Web Services上传和下载图片文件
  2. 惊天大神坑 关于 python-socketio 与 socket.io-client 版本兼容问题
  3. mac 下载的破解软件显示 文件已损坏
  4. sql server 数据库还原
  5. oracle选择外键列,Oracle外键列上是否需要索引?
  6. Centos7 Greenplum6.1开源版本集群部署
  7. 视频转换工具(命令行)
  8. c语言常考的程序,复试C语言常考趣味程序方案.doc
  9. 数据结构实验三 树的遍历生成树
  10. Android为网络请求自定义加载动画