/*************************************************************************
> 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. java-IO处理类的序列化与反序列化

    package TestIo; import java.io.*; /** * 序列化 * * * 对象序列化 * * 一 创建对象 需要说明,想序列化的对象一定要是实现Serivalizable接口 ...

  2. EF Core注意事项

    流程:https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/new-db 1.Both Entity Framework 6. ...

  3. Linux命令应用大词典-第13章 用户和组群管理

    13.1 useradd:创建用户账户 13.2 adduser:创建用户账户 13.3 lnewusers:创建用户账户 13.4 usermod:修改用户账户 13.5 userdel:删除用户账 ...

  4. 第一阶段·Linux运维基础-第2章·Linux系统目录结构介绍

    01 变量与PS1 02 添加用户 03 关闭SELinux 04 关闭iptables 05 显示中文乱码排查过程 06 总结 07 目录结构课程内容 08 Linux目录结构特点 09 Linux ...

  5. 微服务框架Dubbo与Springcloud的区别

    微服务框架Dubbo与Springcloud的区别 微服务主要的优势如下: 1.降低复杂度 将原来偶合在一起的复杂业务拆分为单个服务,规避了原本复杂度无止境的积累.每一个微服务专注于单一功能,并通过定 ...

  6. PAT - L2-001. 紧急救援( Dijstra )

    - PAT - L2-001. 紧急救援 题目链接 作为一个城市的应急救援队伍的负责人,你有一张特殊的全国地图.在地图上显示有多个分散的城市和一些连接城市的快速道路.每个城市的救援队数量和每一条连接两 ...

  7. 最短路径算法(II)

    什么??你问我为什么不在一篇文章写完所有方法?? Hmm…其实我是想的,但是博皮的加载速度再带上文章超长图片超多的话… 可能这辈子都打不开了吧… 上接https://www.cnblogs.com/U ...

  8. python 智能合约日志操作

    from __future__ import unicode_literals import json from time import sleep, time # 中文编码 def encode_s ...

  9. chameleon-Mini(迷你变色龙)

    Chameleon Mini(迷你变色龙)是一个比一般信用卡稍大的小型开发板,是开源产品. 如图 Chameleon Mini可以完全复制许多商业非接触式智能卡包括UID卡,在内的全部内容,因此可以用 ...

  10. URAL 1664 Pipeline Transportation(平面图最大流)

    Description An oligarch Vovan, as many other oligarchs, transports oil from West Cuckooland to East ...