zoukankan      html  css  js  c++  java
  • B

    原题地址:http://code-festival-2017-quala.contest.atcoder.jp/tasks/code_festival_2017_quala_b

    Time limit : 2sec / Memory limit : 256MB

    Score : 200 points

    Problem Statement

    We have a grid with N rows and M columns of squares. Initially, all the squares are white.

    There is a button attached to each row and each column. When a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa. When a button attached to a column is pressed, the colors of all the squares in that column are inverted.

    Takahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid.

    Constraints

    • 1≤N,M≤1000
    • 0≤KNM

    Input

    Input is given from Standard Input in the following format:

    N M K
    

    Output

    If Takahashi can have exactly K black squares in the grid, print Yes; otherwise, print No.


    Sample Input 1

    Copy
    2 2 2
    

    Sample Output 1

    Copy
    Yes
    

    Press the buttons in the order of the first row, the first column.


    Sample Input 2

    Copy
    2 2 1
    

    Sample Output 2

    Copy
    No
    

    Sample Input 3

    Copy
    3 5 8
    

    Sample Output 3

    Copy
    Yes
    

    Press the buttons in the order of the first column, third column, second row, fifth column.


    Sample Input 4

    Copy
    7 9 20
    

    Sample Output 4

    Copy
    No
    题目意思:给一个N*M的方格,刚开始都是白色的,每次可以对一列或一行进行操作;
          使颜色反向;问是否可以得到K个黑色方块;
    解题思路:遍历进行行列的操作;看是否可以出现K个方块;
    #include<iostream>
    #include<string>
    #include<algorithm>
    #include <string.h>
    #include <stdio.h>
    #include <math.h>
    #include <set>
    #include <queue>
    #include <stack>
    #include <map>
     
    using namespace std;
    typedef long long LL;
    const int INF = int(1e9);
     
    int main()
    {
        int N,M,K;
        cin>>N>>M>>K;
        for(int i = 0;i<=N;i++){
            for(int j = 0;j<=M;j++){
                int temp = i*M+j*N -2*i*j;
                if(temp==K)
                {
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
     
        cout<<"No"<<endl;
     
        return 0;
    }
     
  • 相关阅读:
    MySql数据库水平扩展过程
    (转)MySQL数据库水平切分的实现原理解析
    SVN安装使用
    servlet基础
    数据库读写分离的性能分析
    java的可变长参数
    java消息服务
    static/final成员与多态
    商业软件与开源软件
    托管堆
  • 原文地址:https://www.cnblogs.com/a2985812043/p/7749310.html
Copyright © 2011-2022 走看看