博客
关于我
D. Timofey and rectangles[四色定理]
阅读量:529 次
发布时间:2019-03-08

本文共 1168 字,大约阅读时间需要 3 分钟。

关于数学中的三个大猜想之一,歌德巴赫猜想和费马大定理,以及另外一个尚未确定的数学猜想,由某大学生提出。

题意:给n个矩形的坐下角坐标和右上角坐标。问如何用四种颜色进行染色,使得相邻矩形颜色不同。

思路:一定有解。

  • 对左下角坐标进行讨论
  • 奇偶偶奇偶偶奇奇

    如果左下角为奇偶,那么左下角也是奇偶的矩形一定不会与这个矩形相邻(通过绘制坐标图证明四个角的坐标奇偶性)。

    #include 
    #define PI acos(-1.0)#define pb push_back#define F first#define S second#define debug puts#define setp cout << fixed << setprecision(15)#define FAST_IO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); using namespace std;typedef long long ll;const int N = 2e3 + 3;const int MOD = 998244373;ll rain[N], dp[N], u[N];int main(void) { FAST_IO; cout << "YES" << endl; for (int i = 1; i <= n; i++) { int a, b, c, d; cin >> a >> b >> c >> d; if (a < 0) a = -a; if (b < 0) b = -b; if (c < 0) c = -c; if (d < 0) d = -d; if (a % 2 == 1 && b % 2 == 1) cout << 1 << endl; else if (a % 2 == 1 && b % 2 == 0) cout << 2 << endl; else if (a % 2 == 0 && b % 2 == 0) cout << 3 << endl; else if (a % 2 == 0 && b % 2 == 1) cout << 4 << endl; } return 0;}

    该代码为何?它是否正确?如何分析其功能?这是什么编程问题?我们需要清理代码,修正错误,提高可读性。代码中涉及的定义和函数是否合理?外部调用的变量是否正确?我们需要重新审视并优化这段代码。代码看起来似乎用于编程竞赛中的数论题,但目前的结构需要重新调整。我们需要遵循严格的编程规范进行修正。

    转载地址:http://uykiz.baihongyu.com/

    你可能感兴趣的文章
    Objective-C实现lfu cache缓存算法(附完整源码)
    查看>>
    Objective-C实现LFU缓存算法(附完整源码)
    查看>>
    Objective-C实现linear algebra线性代数算法(附完整源码)
    查看>>
    Objective-C实现linear congruential generator线性同余发生器算法(附完整源码)
    查看>>
    Objective-C实现linear discriminant analysis线性判别分析算法(附完整源码)
    查看>>
    Objective-C实现linear regression线性回归算法(附完整源码)
    查看>>
    Objective-C实现linear search线性搜索算法(附完整源码)
    查看>>
    Objective-C实现Linear search线性搜索算法(附完整源码)
    查看>>
    Objective-C实现LinearSieve线性素数筛选算法 (附完整源码)
    查看>>
    Objective-C实现LinkedListNode链表节点类算法(附完整源码)
    查看>>
    Objective-C实现LinkedList链表算法(附完整源码)
    查看>>
    Objective-C实现local weighted learning局部加权学习算法(附完整源码)
    查看>>
    Objective-C实现logistic regression逻辑回归算法(附完整源码)
    查看>>
    Objective-C实现logistic sigmoid函数(附完整源码)
    查看>>
    Objective-C实现longest Common Substring最长公共子串算法(附完整源码)
    查看>>
    Objective-C实现longest increasing subsequence最长递增子序列算法(附完整源码)
    查看>>
    Objective-C实现longestCommonSubsequence最长公共子序列算法(附完整源码)
    查看>>
    Objective-C实现LongestIncreasingSubsequence最长递增子序列算法(附完整源码)
    查看>>
    Objective-C实现lorenz transformation 洛伦兹变换算法(附完整源码)
    查看>>
    Objective-C实现Lower-Upper Decomposition上下分解算法(附完整源码)
    查看>>