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;
    }
  • 相关阅读:
    Hadoop-CDH源码编译
    HBase框架基础(四)
    HBase框架基础(三)
    Scala基础简述
    HBase框架基础(一)
    NOI2015 软件包管理器
    可持久化数据结构入门
    树链剖分 入门
    NOIP2009 最优贸易
    高斯消元 模板
  • 原文地址:https://www.cnblogs.com/handsomecui/p/5204376.html
Copyright © 2011-2022 走看看