zoukankan      html  css  js  c++  java
  • Rikka with Chess(规律)

    Rikka with Chess

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 84    Accepted Submission(s): 72

    Problem Description
    Yuta gives Rikka a chess board of size n×m.
    As we all know, on a chess board, every cell is either black or white and every two cells that share a side have different colors.
    Rikka can choose any rectangle formed by board squares and perform an inversion, every white cell becomes black, and vice versa.
    Rikka wants to turn all cells into the same color, please tell Rikka the minimal number of inversions she need to achieve her goal.
     
    Input
    The first line contains a number T(T10) ——The number of the testcases.
    Each testcase contains two numbers n,m(n109,m109).
     
    Output
    For each testcase, print a single number which represents the answer.
     
    Sample Input
    3 1 2 2 2 3 3
     
    Sample Output
    1 2 2
     
     
    题解:很好找的规律,第二组数据:
    101
    010
    101
    把第二行反转
    101
    101
    101
    把第二列反转
    111
    111
    111
    由此可得:
    直接行列减半取整即可;
    代码:
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<cmath>
    #include<vector>
    using namespace std;
    const int INF=0x3f3f3f3f;
    #define mem(x,y) memset(x,y,sizeof(x))
    #define SI(x) scanf("%d",&x)
    #define PI(x) printf("%d",x)
    #define SD(x,y) scanf("%lf%lf",&x,&y)
    #define P_ printf(" ")
    const int MAXN=1010;
    typedef long long LL;
    int main(){
        int T,N,M;
        SI(T);
        while(T--){
            SI(N);
            SI(M);
            printf("%d
    ",N/2+M/2);
        }
        return 0;
    }
  • 相关阅读:
    把word文档转换成swf格式
    利用“审阅”批改作业
    注意:QQ空间加密并不安全
    MySQLDB 错误 InterfaceError(0,")
    Linux 文件大小 文件夹大小 磁盘大小
    JavaArrays类fill()方法详解
    构造函数
    ASP部署错误"未能加载类型..."
    试AJAX出错两则
    ASP.Net如何区分开发状态与实际应用状态
  • 原文地址:https://www.cnblogs.com/handsomecui/p/5204376.html
Copyright © 2011-2022 走看看