/*************************************************************************
> File Name: L.cpp
> Author: LyuCheng
> Created Time: 2017-12-03 17:31
> Description:
题意:首先有一个乘法表,然后给你一个n*m的矩阵,里面有不确定的数,然
后问你,这个表可不可能是乘法表的一部分 思路:暴力判断每个点
************************************************************************/ #include <bits/stdc++.h> #define MAXN 1234
#define MAXM 12
#define LL long long using namespace std; struct Point{
int x,y;
LL val;
Point(){}
Point(int _x,int _y,LL _val){
x=_x;
y=_y;
val=_val;
}
}; int t;
int n,m;
LL mapn[MAXN][MAXN];
char str[MAXM];
bool flag;
vector<Point>P; inline LL cal(char str[]){
int len=strlen(str);
LL s=;
for(int i=;i<len;i++){
s*=;
s+=str[i]-'';
}
return s;
} inline bool judge(LL x,LL y,LL fx,LL fy){
for(int i=;i<(int)P.size();i++){
if((fx+P[i].x-x)*(fy+P[i].y-y)!=P[i].val)
return false;
}
return true;
} inline void init(){
P.clear();
flag=false;
} int main(){
// freopen("in.txt","r",stdin);
scanf("%d",&t);
for(int ca=;ca<=t;ca++){
printf("Case #%d: ",ca);
init();
scanf("%d%d",&n,&m);
for(LL i=;i<=n;i++){
for(LL j=;j<=m;j++){
scanf("%s",str);
if(str[]!='?'){
mapn[i][j]=cal(str);
P.push_back(Point(i,j,mapn[i][j]));
}else{
mapn[i][j]=;
}
}
}
if((int)P.size()==){
puts("Yes");
}else {
for(LL i=;i*i<=P[].val;i++){
if(P[].val%i==){
LL fx=i;
LL fy=P[].val/i;
if(fx>=P[].x&&fy>=P[].y)
if(judge(P[].x,P[].y,fx,fy)==true){
flag=true;
break;
}
swap(fx,fy);
if(fx>=P[].x&&fy>=P[].y)
if(judge(P[].x,P[].y,fx,fy)==true){
flag=true;
break;
}
}
}
puts(flag==true?"Yes":"No");
}
}
return ;
}

2015 EC L - Multiplication Table的更多相关文章

  1. UVALive 7511 L - Multiplication Table 数学模拟题,暴力

    给定一副表,问其是否合法. 思路:当全部是?的时候,是合法的. 如果不是,那么,就找到一个数字,把它拆成若干个a*b的形式,去判断其它点是否合法即可. 拆分数字的时候,只需要枚举到sqrt(n),因为 ...

  2. cf448D Multiplication Table

    D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input stand ...

  3. Codeforces Round #256 (Div. 2) D. Multiplication Table(二进制搜索)

    转载请注明出处:viewmode=contents" target="_blank">http://blog.csdn.net/u012860063?viewmod ...

  4. Codeforces Round #256 (Div. 2) D. Multiplication Table 二分法

     D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input st ...

  5. Codeforces 448 D. Multiplication Table 二分

    题目链接:D. Multiplication Table 题意: 给出N×M的乘法矩阵要你求在这个惩罚矩阵中第k个小的元素(1 ≤ n, m ≤ 5·10^5; 1 ≤ k ≤ n·m). 题解: n ...

  6. 668. Kth Smallest Number in Multiplication Table

    Nearly every one have used the Multiplication Table. But could you find out the k-th smallest number ...

  7. LeetCode hard 668. Kth Smallest Number in Multiplication Table(二分答案,一次过了,好开心,哈哈哈哈)

    题目:https://leetcode.com/problems/kth-smallest-number-in-multiplication-table/description/ 668. Kth S ...

  8. 洛谷 CF448D Multiplication Table

    目录 题目 思路 \(Code\) 题目 CF448D Multiplication Table 思路 二分答案.这个矩阵的每一排都是递增的,所以二分\(ans\),去计算有多少个数等于\(ans\) ...

  9. Day8 - D - Multiplication Table CodeForces - 448D

    Bizon the Champion isn't just charming, he also is very smart. While some of us were learning the mu ...

随机推荐

  1. Netty概述

    一,介绍 Netty是由JBOSS提供的一个java开源框架.Netty提供异步的.事件驱动的网络应用程序框架和工具,用以快速开发高性能.高可靠性的网络服务器和客户端程序. 也就是说,Netty 是一 ...

  2. CLR via c#读书笔记九:接口

    1.接口对一组方法签名进行了统一命名.接口还能定义事件.无参属性和有参属性(C#的索引器). 2.c#禁止接口定义任何一种静态成员. 3.C#编译器要求将实现接口的方法标记为public.CLR要求将 ...

  3. outer join test

    create table t1_outerjoin(a int, b int , c int); create table t2_outerjoin(a int); create table t3_o ...

  4. 记录---Testin上新手测试用例设计实战---碎乐3.2.0

    平台上给的版本是碎乐3.12版的,但是平台上给的安装包下载不了,所以加群咨询之后给出了直接去手机应用商店下载搜索到的版本的对策.所以就那应用商店中找到的3.2.0版本来设计测试用例.因为任务中没有给出 ...

  5. Java开发工程师(Web方向) - 04.Spring框架 - 第3章.AOP技术

    第3章--AOP技术 Spring框架 - AOP概述 笔记https://my.oschina.net/hava/blog/758873Spring框架 - AOP使用 笔记https://my.o ...

  6. Navicat和DBeaver的查询快捷键

    1.Navicat for MySQL(连接MySQL数据库的工具) ctrl + r 执行查询页中所有的sql语句 ctrl + shift + r 只运行选中的sql语句 2.DBeaver(支持 ...

  7. TW实习日记:第16天

    前端的样式bug实在是太太太莫名其妙了,尤其是封装好的组件,一层套一层的,根本不知道是哪一层出了问题...除了改bug就是做新功能,真想吐槽一下这个项目的留言板,根本没人会用吧...这功能实在是太老旧 ...

  8. 硬盘基础知识&&分区

    学习记录的笔记,虽然毫无章法 硬盘基础知识 磁盘的物理组成 如下图所示: 有关磁盘物理知识的详细介绍请看硬盘的存储原理和内部架构这篇博文 硬盘接口类型 IDE SATA SCSI SAS 光纤通道 I ...

  9. leetcode-最大子序和(动态规划讲解)

    最大子序和(动态规划讲解) 给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和. 示例: 输入: [-2,1,-3,4,-1,2,1,-5,4], 输 ...

  10. leetcode-数数并说

     数数并说     报数序列是指一个整数序列,按照其中的整数的顺序进行报数,得到下一个数.其前五项如下: 1. 1 2. 11 3. 21 4. 1211 5. 111221 1 被读作  " ...