289B. Polo the Penguin and Matrix
生活随笔
收集整理的這篇文章主要介紹了
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的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 极光推送源码api封装改造
- 下一篇: 如何解压bz2后缀的压缩文件