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;
    }
  • 相关阅读:
    [Micropython]发光二极管制作炫彩跑马灯
    如何在MicroPython TPYBoard 添加自定义类库
    micropython TPYBoard v202 超声波测距
    简易排水简车的制作 TurnipBit 系列教程
    TPYBoard v102 驱动28BYJ-48步进电机
    使用mksdcard管理虚拟SD卡
    使用 DX 编译 Android应用
    常用ADB的用法
    在命令行创建、删除和浏览AVD、使用android模拟器
    Android-SDK下目录结构
  • 原文地址:https://www.cnblogs.com/handsomecui/p/5204376.html
Copyright © 2011-2022 走看看