• HDU 3359 Kind of a Blur(高斯消元)


    题意:

           H * W (W,H <= 10) 的矩阵A的某个元素A[i][j],从它出发到其他点的曼哈顿距离小于等于D的所有值的和S[i][j]除上可达点的数目,构成了矩阵B。给定矩阵B,求矩阵A。

    题目先给宽再给高。。。坑我了一个小时

    code

    /*
           暴力确定每个位置有到那些位置的曼哈顿距离小于D
           然后对你n*m个未知数,n*m个方程进行高斯消元
    */
    #include <iostream>
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    using namespace std;
    
    const int MAXN = 111;
    int n, m, dx, cnt;
    double A[MAXN][MAXN], ans[MAXN];
    inline void build (int x, int y, int d) {
        int k = 0;
        for (int i = 0, tol = 0; i < n; ++i)
            for (int j = 0; j < m; ++j) {
                if (abs (i - x) + abs (j - y) <= dx)
                    A[d][tol++] = 1, ++k;
                else
                    A[d][tol++] = 0;
            }
        A[d][cnt] *= k;
    }
    void Gauss() {
        int i, j, k;
        double tmp, big;
        for (i = 0; i < cnt; i++) {
            for (big = 0, j = i; j < cnt; j++) {
                if (abs (A[j][i]) > big) {
                    big = abs (A[j][i]);
                    k = j;
                }
            }
            if (k != i) {
                for (j = 0; j <= cnt; j++)
                    swap (A[i][j], A[k][j]);
            }
            for (j = i + 1; j < cnt; j++) {
                if (A[j][i]) {
                    tmp = -A[j][i] / A[i][i];
                    for (k = i; k <= cnt; k++)
                        A[j][k] += tmp * A[i][k];
                }
            }
        }
        for (i = cnt - 1; i >= 0; i--) {
            tmp = 0;
            for (j = i + 1; j < cnt; j++)
                tmp += A[i][j] * ans[j];
            ans[i] = (A[i][j] - tmp) / A[i][i];
        }
    }
    int main() {
        int cs = 0;
        while (scanf ("%d %d %d", &m, &n, &dx), n) {
            if (cs == 0) cs = 1;
            else
                putchar (10);
            cnt = n * m;
            for (int i = 0, tol = 0; i < n; ++i)
                for (int j = 0; j < m; ++j)
                    scanf ("%lf", &A[tol++][cnt]);
            for (int i = 0, tol = 0; i < n; ++i)
                for (int j = 0; j < m; ++j, ++tol)
                    build (i, j, tol);
            Gauss ();
            for (int i = 0, cnt = 0; i < n; i++) {
                for (int j = 0; j < m; j++)
                    printf ("%8.2f", ans[cnt++]);
                putchar (10);
            }
        }
        return 0;
    }
    View Code
  • 相关阅读:
    Android播放器实现视频窗口实时放大缩小功能
    Spydroid还是大牛直播内置RTSP服务SDK
    安卓端/iOS端如何播放4K分辨率的RTMP/RTSP流
    mingw64+msys2下使用cmake问题
    h264, h265 和 libvpx 比较(h264/avc, hevc 和vp9比较)
    直播协议的选择:RTMP vs. HLS
    如何推送和播放RTMP H265流 (RTMP HEVC)
    如何支持RTSP播放H.265(HEVC)流
    如何实现RTSP推送H.264、RTSP推送H.265(hevc)
    rtmp/rtsp/hls公网测试地址
  • 原文地址:https://www.cnblogs.com/keam37/p/4050463.html
Copyright © 2020-2023  润新知