Frame

题目链接:

http://acm.hust.edu.cn/vjudge/contest/130303#problem/D

Description


http://7xjob4.com1.z0.glb.clouddn.com/17e6574035df3f9b6d1fc6dfd8b650ac

Input


The input file contains several test cases, each of them as described below.
The first line contains 2 integers — X and Y (3 ≤ X ≤ 10^6, 3 ≤ Y ≤ 10^6). The second line
contains integer N — the number of tile types to be analyzed (1 ≤ N ≤ 1000). Each of following N
lines contains one integer, not exceeding 10^6. We designate with AK the integer on the (k + 2)-th line of the input file.

Output


For each test case, your goal is to print N lines, where the K-th line should contain the word ‘YES’, if it is possible to tile the frame with size X × Y with tiles AK × 1, and the word ‘NO’ otherwise.

Sample Input


```
5 6
2
3
4
```

Sample Output


```
YES
NO
```

Source


2016-HUST-线下组队赛-4


##题意:

在X*Y的矩形的最外圈放若干个 A*1 的小矩形,判断对于给定的A能够恰好完全覆盖.


##题解:

考虑最上面一行的情况,第一块小矩形要么从#(1,1)开始,要么从#(1,2)开始(留出第一格给竖的矩形).
确定第一块的位置后,后面的摆放情况是固定的,所以依次判断一下是否合法即可.


##代码:
``` cpp
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define LL long long
#define maxn 101000
#define inf 0x3f3f3f3f
#define mod 1000000007
#define mid(a,b) ((a+b)>>1)
#define eps 1e-8
#define IN freopen("in.txt","r",stdin);
using namespace std;

int n;

int x,y;

bool solve(int a) {

int last1 = x % a;

if(last1 > 1) return 0;

if(last1 == 1) {

int last2 = y % a;

if(last2 > 1) return 0;

if(last2 == 1) return 1;

if(last2 == 0) return (y-2) % a == 0;

}

if(last1 == 0) {

int last2 = (y-1) % a;

if(last2 > 1) return 0;

if(last2 == 1) return 1;

if(last2 == 0) return (x-2) % a == 0;

}

}

bool solve2(int a) {

int last1 = (x-1) % a;

if(last1 > 1) return 0;

if(last1 == 1) {

int last2 = y % a;

if(last2 > 1) return 0;

if(last2 == 0) return 1;

if(last2 == 1) return x % a == 0;

}

if(last1 == 0) {

int last2 = (y-1) % a;

if(last2 > 1) return 0;

if(last2 == 0) return 1;

if(last2 == 1) return y % a == 0;

}

}

int main()

{

//IN;

while(scanf("%d %d", &x,&y) != EOF)
{
swap(x,y);
int n; scanf("%d", &n);
while(n--) {
int a; scanf("%d", &a);
if(solve(a) || solve2(a)) puts("YES");
else puts("NO");
}
} return 0;

}

UVALive 6858 Frame (模拟)的更多相关文章

  1. UVaLive 6858 Frame (水题)

    题意:给定一个矩形框架,给定一个小矩形,问你能不能正好拼起来. 析:很简单么,就三种情况,如果是1*1的矩形,或者是1*2的一定可以,然后就是上面和下面正好能是小矩形的整数倍,左右是少一,两个就是整数 ...

  2. UVALive 4222 Dance 模拟题

    Dance 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&pag ...

  3. UVALive 3971 Assemble(模拟 + 二分)

    UVALive 3971 题意:有b块钱.想要组装一台电脑,给出n个配件的种类,名字,价格,品质因子.若各种类配件各买一个,总价格<=b,求最差品质配件的最大品质因子. 思路: 求最大的最小值一 ...

  4. UVALive 6451:Tables(模拟 Grade D)

    VJ题目链接 题意:模拟输出表格 思路:模拟……很暴力 代码: #include <cstdio> #include <cstring> #include <cstdli ...

  5. UVALive 3634 数据结构模拟

    这题真是坑啊,题意不明,其实就是往桟里面压入空的set集合,所以之前的询问大小都是只有0,只有add的时候,才会产生新的占空间的集合 用stack和set直接进行模拟 #include <ios ...

  6. UVALive - 6440(模拟)

    题目链接:https://vjudge.net/contest/241341#problem/G 题目大意:输入一个N,n次操作.对于第一种操作增加一个病人,告诉病人的t0,st0,r.第二种操作,在 ...

  7. UVALive 7327【模拟】

    题意: 每次方案一个或多个子序列: 每个子序列要整除m 认为分割不同,子序列边界的不同就是不同: 1246有4个 1246 12 46 124 6 12 4 6 思路: 先从整体考虑,因为取膜适用于加 ...

  8. UVALive 6833【模拟】

    题意: 算从左往右的值,先乘后加的值,数的范围<=9= =,然后根据满足的条件输出字符. 思路: 从左往右就是直接来了,先做乘法就是乘法两边的数字靠向右边那个,且左边那个为0,然后所有值一加就好 ...

  9. UVALive 6858——分类讨论&&水题

    题目 链接 题意:对于一个$n \times m$的矩阵的最外一圈,问是否能用$k \times 1$的方块填满 分析 考虑左右两边的情况,分类讨论,切记考虑所有可能的情形. #include< ...

随机推荐

  1. Redis进阶:Redis的主从复制机制

    Redis进阶:Redis的主从复制机制 主从复制机制介绍 单机版的Redis存在性能瓶颈,Redis通过提高主从复制实现读写分离,提高了了Redis的可用性,另一方便也能实现数据在多个Redis直接 ...

  2. 开篇——从程序员到IT经理

    2002年~2005年我在广州的广东水力电力职业技术学院求学,主修网络工程.求学期间,我从事最多的就是玩游戏,当时就是玩MU和CS,所以有一门编程课叫C语言的“肥佬”(广东话)了,要补考,没办法,于是 ...

  3. Java - Java Mail邮件开发(2)springboot +Java Mail + Html

    1.springboot + Java Mail + Html 项目结构: pom.xml <project xmlns="http://maven.apache.org/POM/4. ...

  4. HDU 1043 Eight 八数码问题 A*算法(经典问题)

    HDU 1043 Eight 八数码问题(经典问题) 题意 经典问题,就不再进行解释了. 这里主要是给你一个状态,然后要你求其到达\(1,2,3,4,5,6,7,8,x\)的转移路径. 解题思路 这里 ...

  5. python内存管理(通俗易懂,详细可靠)

    python内存管理 python3.6.9 内存管理的官方文档 https://docs.python.org/zh-cn/3.6/c-api/memory.html 一.变量存哪了? x = 10 ...

  6. WindowsForms使用Telerik Reporting

    新建一个WindowsForms窗体项目 然后拖动ReportViewer这个控件到WindowsForms的窗体中 如上图所示,用来呈现报表的控件,这个控件可以打印报表,转换报表这类的功能 接下来我 ...

  7. express热更新nodemon,自启动项目

    一.说一下 每次修改文件,我们都需要重启服务器npm start,很麻烦,所以使用引入nodemon插件,解决这个问题,实现保存文件,即自启动刷新项目 二.直接开码 npm install nodem ...

  8. c++ Socket客户端和服务端示例版本三(多线程版本)

    客户端 #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <sys/soc ...

  9. Docker介绍,安装和常用的命令

    Docker是Google公司推出的Go语言开发的,基于Linux内核的cgroup,namespace,AUFS类的UnionFS等技术.对进程进行封装格力,属于操作系统层面的虚拟化技术.隔离的进程 ...

  10. 2019 计蒜之道 复赛 E. 撑起信息安全“保护伞” (贪心,构造,规律)

    为了给全球小学员打起信息安全"保护伞",VIPKID 还建立了一套立体化的安全防御体系,7 \times 247×24 小时持续安全监控与应急响应等多项联动,具备业界最高级别的数据 ...