2015 EC L - Multiplication Table
/*************************************************************************
> 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的更多相关文章
- UVALive 7511 L - Multiplication Table 数学模拟题,暴力
给定一副表,问其是否合法. 思路:当全部是?的时候,是合法的. 如果不是,那么,就找到一个数字,把它拆成若干个a*b的形式,去判断其它点是否合法即可. 拆分数字的时候,只需要枚举到sqrt(n),因为 ...
- cf448D Multiplication Table
D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Codeforces Round #256 (Div. 2) D. Multiplication Table(二进制搜索)
转载请注明出处:viewmode=contents" target="_blank">http://blog.csdn.net/u012860063?viewmod ...
- 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 ...
- Codeforces 448 D. Multiplication Table 二分
题目链接:D. Multiplication Table 题意: 给出N×M的乘法矩阵要你求在这个惩罚矩阵中第k个小的元素(1 ≤ n, m ≤ 5·10^5; 1 ≤ k ≤ n·m). 题解: n ...
- 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 ...
- LeetCode hard 668. Kth Smallest Number in Multiplication Table(二分答案,一次过了,好开心,哈哈哈哈)
题目:https://leetcode.com/problems/kth-smallest-number-in-multiplication-table/description/ 668. Kth S ...
- 洛谷 CF448D Multiplication Table
目录 题目 思路 \(Code\) 题目 CF448D Multiplication Table 思路 二分答案.这个矩阵的每一排都是递增的,所以二分\(ans\),去计算有多少个数等于\(ans\) ...
- 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 ...
随机推荐
- vim 安装
Ubuntu 16.04 下 Vim安装及配置 默认已经安装了VIM-tiny linuxidc@linuxidc:~$ locate vi | grep 'vi$' |xargs ls -al lr ...
- Weka java.lang.reflect.InvocationTargetException
在用Weka导入数据的时候报 java.lang.reflect.InvocationTargetException 错误,Weka运行包没有给出详细的错误信息,无法查到. 直接调试Weka源码,发现 ...
- 读google c++规范笔记
全局变量在main函数之前初始化原则上禁止拷贝构造函数和赋值函数如果只有数据,没有方法,可以用struct析构函数声明为虚函数尽量避免重载操作符 难以定位的bug 误以为简单的操作存取控制 可以放到声 ...
- InnoDB意向锁和插入意向锁
Preface Last night one buddy in tech wechat group asked "what's intention locks of Inno ...
- VIN码识别/车架号OCR识别:快速占领汽车后市场数据入口
大数据时代,企业在数据入口方面的竞争越来越激烈,这种对于入口级的大数据“争夺战”,让很多企业在数据挖掘和收集的技术方面开始加快更新速度. 在当前IT行业激烈竞争环境之下,对于入口产品的控制成为了大数据 ...
- C++ 基础面试题-1
请说出下面代码在32位系统下的输出内容 /* ** 2018/03/21 21:43:00 ** Brief: ** Author:ZhangJianWei ** Email:Dream_Dog@16 ...
- Memcache的客户端连接系列(四) PHP
关键词: Memcached PHP 客户端 声明:本文并非原创,转自华为云帮助中心的分布式缓存服务(Memcached)的用户指南.客户端连接方法通用,故摘抄过来分享给大家. PHP客户端 Re ...
- 【第四章】MySQL数据库的基本操作:数据库、表的创建插入查看
MySQL数据库基本操作 创建表 create table 查看表结构 desc table, show create table 表完整性约束 修改表 alter table 复制表 create ...
- oraclize预言机资料
oraclize预言机资料 智能合约如何可信的与外部世界交互: https://blog.csdn.net/sportshark/article/details/77477842 国外一篇讲得很详细的 ...
- Thunder团队第二周 - Scrum会议3
Scrum会议3 小组名称:Thunder 项目名称:爱阅app Scrum Master:代秋彤 工作照片: 参会成员: 王航:http://www.cnblogs.com/wangh013/ 李传 ...