#include <iostream> #include <iomanip> using namespace std; int main() { int n, m; cin >> n >> m; int same_count = 0; int total = n * m; // 正确读取并比较两幅图像的像素 for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { int pixel1, pixel2; cin >> pixel1; // 读取第一幅图像的像素 cin >> pixel2; // 立即读取第二幅图像的对应像素 if (pixel1 == pixel2) { same_count++; // 如果相同则计数加1 } } } // 计算相似度百分比 double similarity = (double)same_count / total * 100; // 输出结果,保留两位小数 cout << fixed << setprecision(2) << similarity << endl; return 0; } /************************************************************** Problem: 1407 User: fuyijun Language: C++ Result: Wrong Answer ****************************************************************/