/*************************************************************************
> 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. CF 1042 E. Vasya and Magic Matrix

    E. Vasya and Magic Matrix http://codeforces.com/contest/1042/problem/E 题意: 一个n*m的矩阵,每个位置有一个元素,给定一个起点 ...

  2. 怎么判断ThreadPool线程池里的任务都执行完毕

    在下面 链接中做方便的应该是第三种方法(他也推荐了),但是第三种方法有个小问题,就是 : WaitHandle.WaitAll(_ManualEvents); 中的_ManualEvents最大为64 ...

  3. 《绝地求生大逃杀》BE错误怎么办 BE服务未正常运行及安装失败解决方法

    <绝地求生大逃杀>BattlEye Launcher是游戏的反作弊程序,也是启动过程中做容易出现错误的,今天小编带来“爆锤吧务”分享的<绝地求生大逃杀>BE服务未正常运行及安装 ...

  4. jieba结巴分词

    pip install jieba安装jieba模块 如果网速比较慢,可以使用豆瓣的Python源:pip install -i https://pypi.douban.com/simple/ jie ...

  5. egrep及扩展正则

    模式:pattern 正则: grep:基本正则,查找速度慢 Extended grep:扩展正则 fgrep:fast grep,不支持正则,直接查找字符串,执行速度快 基本正则: . :任意单个字 ...

  6. 【Linux 运维】 Centos7.x 系统修复模式

    一.linux的运行级别: 运行级别就是来确定系统启动时到底启动那个服务. linux默认有7个运行级别: 0 关机 1 单用户模式,用于系统修复 2 不完全的命令模式,不含NFS服务 3 完全的命令 ...

  7. Halcon和visionPro的比较

    很多朋友会问到visionpro和halcon这两款机器视觉软件,到底学哪个好呢,今天重码网就给大家讲一讲: 首先比较下两者的优缺点: halcon: 提供的图像算法要比Visionpro多,也就是说 ...

  8. Executor Framework

    Why? look at the following 2 pieces of code for implementing a simple web server based on socket, ca ...

  9. SIG蓝牙mesh笔记2_mesh组成

    目录 SIG 蓝牙 mesh 组成 mesh网络概述 网络和子网 设备和节点 devices & nodes 入网 mesh中的几个概念 智能插座例子 SIG 蓝牙 mesh 组成 mesh网 ...

  10. C#之WCF入门1—简单的wcf例子

    第一步:创建一个空的解决方案,新建一个WCF服务应用程序项目(使用默认名字) 来模拟服务端,新建一个控制台应用程序项目(名称改为 ConsoleApp)来模拟客户端. 第二步:简单分析WcfServi ...