1873: 【CSP二维数组】图像相似度▅

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:1 Solved:1

Description

给出两幅相同大小的黑白图像(用 lns="http://www.w3.org/1998/Math/MathML">01 矩阵表示,lns="http://www.w3.org/1998/Math/MathML">0 代表白色,lns="http://www.w3.org/1998/Math/MathML">1 代表黑色)表示,求它们的相似度。

说明:若两幅图像在相同位置上的像素点颜色的值相同,则称它们在该位置具有相同的像素点。两幅图像的相似度定义为相同像素点数占总像素点数的百分比。

比如:输入

2 2
1 0
0 1
1 1
1 1 

数据解释:第一行的 lns="http://www.w3.org/1998/Math/MathML">2 lns="http://www.w3.org/1998/Math/MathML">2 表示图像的尺寸是 lns="http://www.w3.org/1998/Math/MathML">2 行,每行 lns="http://www.w3.org/1998/Math/MathML">2 个整数;接下来的两行数据 lns="http://www.w3.org/1998/Math/MathML">1 lns="http://www.w3.org/1998/Math/MathML">0 和 lns="http://www.w3.org/1998/Math/MathML">0 lns="http://www.w3.org/1998/Math/MathML">1 表示第一幅图片的数值,再接下来两行数据 lns="http://www.w3.org/1998/Math/MathML">1 lns="http://www.w3.org/1998/Math/MathML">1 和 lns="http://www.w3.org/1998/Math/MathML">1 lns="http://www.w3.org/1998/Math/MathML">1 表示第二幅图片的数值;

从数据上可以看出,两幅图片有 lns="http://www.w3.org/1998/Math/MathML">2 个数是相等的,因此两幅图片的相似度为 lns="http://www.w3.org/1998/Math/MathML">50%,实际输出不需要输出百分号,结果保留 lns="http://www.w3.org/1998/Math/MathML">2 位小数,因此实际输出 lns="http://www.w3.org/1998/Math/MathML">50.00 。

Input

第一行包含两个整数 lns="http://www.w3.org/1998/Math/MathML">n 和 lns="http://www.w3.org/1998/Math/MathML">m ,表示图像的行数和列数,中间用单个空格隔开。(lns="http://www.w3.org/1998/Math/MathML">1n,m100

之后 lns="http://www.w3.org/1998/Math/MathML">n 行,每行 lns="http://www.w3.org/1998/Math/MathML">m 个整数 lns="http://www.w3.org/1998/Math/MathML">0 或 lns="http://www.w3.org/1998/Math/MathML">1 ,表示第一幅黑白图像上各像素点的颜色。相邻两个数之间用单个空格隔开。

之后 lns="http://www.w3.org/1998/Math/MathML">n 行,每行 lns="http://www.w3.org/1998/Math/MathML">m 个整数 lns="http://www.w3.org/1998/Math/MathML">0 或 lns="http://www.w3.org/1998/Math/MathML">1 ,表示第二幅黑白图像上各像素点的颜色。相邻两个数之间用单个空格隔开。

Output

一个小数,表示相似度(以百分比的形式给出,但百分号不需要显示),精确到小数点后两位。

Sample Input Copy

2 3
1 0 1
0 1 1
0 1 1
1 0 1

Sample Output Copy

33.33