个人心得:开始拿着题目还是有点懵逼的,以前做过相同的,不过那是按一个位置行列全都反之,当时也是没有深究。现在在打比赛不得不

重新构思,后面一想把所有的状态都找出来,因为每次确定了已经按下的行和列后,按不同的操作所加的数都是一样的,于是就想到了用set

暴力枚举,从1-n个分别行列按钮,然后再枚举不同操作即确定行时再对列进行操作,每次操作放入set就可以了。

题目:

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:

  1. N M K

Output

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


Sample Input 1

Copy
  1. 2 2 2

Sample Output 1

Copy
  1. Yes

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


Sample Input 2

Copy
  1. 2 2 1

Sample Output 2

Copy
  1. No

Sample Input 3

Copy
  1. 3 5 8

Sample Output 3

Copy
  1. Yes

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


Sample Input 4

Copy
  1. 7 9 20

Sample Output 4

Copy
  1. No
  1. #include<iostream>
  2. #include<cstring>
  3. #include<string>
  4. #include<cstdio>
  5. #include<vector>
  6. #include<cmath>
  7. #include<stack>
  8. #include<set>
  9. #include<queue>
  10. #include<algorithm>
  11. using namespace std;
  12. #define in 1000000007
  13. int main()
  14. {
  15. int n,m,p;
  16. cin>>n>>m>>p;
  17. set<int >s;
  18. s.insert();
  19. for(int i=;i<=n;i++)
  20. {
  21. s.insert(i*m);
  22. for(int j=;j<=m;j++)
  23. {
  24. int t=i*m+j*(n-*i);
  25. s.insert(t);
  26. }
  27. }
  28. for(int j=;j<=m;j++)
  29. {
  30. s.insert(j*n);
  31. for(int i=;i<=n;i++)
  32. {
  33. int t=j*n+i*(m-*j);
  34. s.insert(t);
  35. }
  36. }
  37. if(s.count(p)) cout<<"Yes"<<endl;
  38. else cout<<"No"<<endl;
  39. return ;
  40. }
  1.  

CODE FESTIVAL 2017 qual A--B-fLIP(换种想法,暴力枚举)的更多相关文章

  1. [Code Festival 2017 qual A] B: flip

    题意 给出一个n行m列初始全白的矩阵,每次可以翻转一行/一列的全部格子的颜色.问任意次操作后能否使得恰好有k个黑色格子. n,m<=1000 分析 显然要么翻转一次要么不翻转. 最终黑色格子数只 ...

  2. CODE FESTIVAL 2017 qual A B fLIP(补题)

    平时没见过这样的题目,看到后很懵逼.没想到. 思路:按下按钮的顺序并不影响结果,一个按钮要么按一次,要么不按,按多了也没用,比如:按3次和按1次没啥区别. 假设这是个M * N的矩阵,我们已经按下了k ...

  3. CODE FESTIVAL 2017 qual B B - Problem Set【水题,stl map】

    CODE FESTIVAL 2017 qual B B - Problem Set 确实水题,但当时没想到map,用sort后逐个比较解决的,感觉麻烦些,虽然效率高很多.map确实好写点. 用map: ...

  4. CODE FESTIVAL 2017 qual B C - 3 Steps【二分图】

    CODE FESTIVAL 2017 qual B C - 3 Steps 题意:给定一个n个结点m条边的无向图,若两点间走三步可以到,那么两点间可以直接连一条边,已经有边的不能连,问一共最多能连多少 ...

  5. CODE FESTIVAL 2017 qual B

    昨晚因为有点事就去忙了,没打后悔啊 A - XXFESTIVAL Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem ...

  6. [Atcoder Code Festival 2017 Qual A Problem D]Four Coloring

    题目大意:给一个\(n\times m\)的棋盘染四种颜色,要求曼哈顿距离为\\(d\\)的两个点颜色不同.解题思路:把棋盘旋转45°,则\((x,y)<-(x+y,x-y)\).这样就变成了以 ...

  7. 题解【AtCoder - CODE FESTIVAL 2017 qual B - D - 101 to 010】

    题目:https://atcoder.jp/contests/code-festival-2017-qualb/tasks/code_festival_2017_qualb_d 题意:给一个 01 串 ...

  8. 【AtCoder】CODE FESTIVAL 2017 qual A

    A - Snuke's favorite YAKINIKU -- #include <bits/stdc++.h> #define fi first #define se second # ...

  9. 【AtCoder】CODE FESTIVAL 2017 qual B

    最近不知道为啥被安利了饥荒,但是不能再玩物丧志了,不能颓了 饥荒真好玩 A - XXFESTIVAL CCFESTIVAL #include <bits/stdc++.h> #define ...

随机推荐

  1. iOS 9 的新功能 universal links

    什么是 universal links: (通用链接) 一种能够方便的通过传统 HTTP 链接来启动 APP, 使用相同的网址打开web page和 APP的方式. 第一点,链接打开网址 顾名思义 第 ...

  2. openGL学习进程(1)OpenGL的简介

        通过本节,我们来简要了解一下openGL.     (1)OpenGL概述: openGL(Open Graphics Library)是个专业的图形程序接口,定义了一个跨编程语言.跨平台的编 ...

  3. Linux文件系统管理 fdisk分区命令

    概述 我们在安装操作系统的过程中已经对系统硬盘进行了分区,但是如果我新添加了一块硬盘,想要正常使用时,在Linux中有专门的分区命令 fdisk 和 parted.其中 fdisk 命令较为常用,但不 ...

  4. Python编程-绑定方法、软件开发

    一.绑定方法与非绑定方法 1.绑定方法 绑定给谁,谁来调用就自动将它本身当作第一个参数传入 (1)绑定到类的方法:用classmethod装饰器装饰的方法. 为类量身定制 类.boud_method( ...

  5. 主攻ASP.NET.4.5.1 MVC5.0之重生:政府行政网站常用友情链接跳转javascript[干货分享]

    <!-----------------------------------> <script language="JavaScript" type="t ...

  6. 外网IP地址API

    新浪的IP地址查询接口:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js 新浪多地域测试方法:http://int.dpool. ...

  7. Android LCD(三):LCD接口篇【转】

    本文转载自:http://blog.csdn.net/xubin341719/article/details/9177085 关键词:Android LCD控制器 Framebuffer PWM  平 ...

  8. 通过join方法顺序执行多个线程

    方法一:直接用多线程之间的通讯去解决 package com.toov5.test; import javax.imageio.ImageTypeSpecifier; class Res1{ char ...

  9. mongodb,redis简单学习

     2.mongodb安装配置简单学习                   配置好数据库路径就可以mongo命令执行交互操作了:先将服务器开起来:在开个cmd执行交互操作                 ...

  10. jQuery颜色面板插件

    /** * jQuery颜色面板插件 * * 使用方法:input框的id默认为inputObj,button框的id默认为btnObj,也可以自定义aaa,bbb * 1.初始化颜色面板:$.col ...