289B. Polo the Penguin and Matrix
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相关推荐
- Polo the Penguin and Matrix
Little penguin Polo has an n × m matrix, consisting of integers. Let's index the matrix rows from 1 ...
- 【CodeForces - 289E 】Polo the Penguin and XOR operation (数学,异或,贪心)
题干: Little penguin Polo likes permutations. But most of all he likes permutations of integers from 0 ...
- 【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 ...
- 【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 ...
- codechef Polo the Penguin and the Tree
一般xor 的题目都是用trie解决. 那这道题是在树上的trie; 首先:从root==1,遍历树得到1到所有节点的xor 值. 然后对于每个点我们把其插入二进制树中. 对于每一个点查找其二进值异或 ...
- Codeforces Round #177 (Div. 1)C. Polo the Penguin and XOR operation【贪心】
http://codeforces.com/contest/288/problem/C 按二进制位从大到小进行匹配 #include <cstdio> #include <cstri ...
- 【Codeforces】A2组刷题记录(50 / 50)完结
目录 A1. Counterexample A2. Good Number A3. Dice Tower ★A4. Alyona and Numbers A5. Mountain Scenery rz ...
- Android 自定义View ——Matrix (矩阵)
Matrix的作用: Matrix类包含一个3x3矩阵,用于转换坐标 Matrix (矩阵) 的原理很遗憾自己目前也是含糊的很,这里就不说了,记录自己在项目使用的方法, 这里就简单的记录下Matrix ...
- Codeforces 903F Clear The Matrix(状态压缩DP)
题目链接 Clear The Matrix 题意 给定一个$4 * n$的矩形,里面的元素为$'.'$或$'*'$.现在有$4$种正方形可以覆盖掉$'*'$,正方形的边长分别为$1,2,3,4$. 求 ...
最新文章
- android 线程 wait notify
- 怎么一键备份服务器系统还原,电脑怎么一键还原
- PHP语言特性和各版本的差异
- android jar 加密
- 新春大吉,2017 Make .NET Great
- message:MCODE参数不存在,mobile类型mcode参数必需
- 计算机网络 第一章 计算机网络和因特网
- jQuery插件开发的准备
- 如何制作一款HTML5 RPG游戏引擎——第二篇,烟雨+飞雪效果
- spring cloud构建互联网分布式微服务云平台-高可用的服务注册中心
- java odbc timesten_TimesTen ODBC 链接库差异及相关命令行工具的使用注意事项
- Java输入输出流体系
- android 七彩进度条背景图片,Android编程实现自定义ProgressBar样式示例(背景色及一级、二级进度条颜色)...
- 6plus经常显示无服务器,苹果6plus屏幕失灵怎么办?如何解决?
- 分子动力学软件-VMD(win版)
- 北邮硕士、前百度工程师:能进大厂,就不用读研究生了!
- 学会这些快准狠的Word技巧,你也能成为Word高手
- VVC帧间预测(十)帧间帧内联合预测CIIP
- The Shawshank Redemption-6
- 模拟通讯录系统2.0