Image Transformation


Time Limit: 2 Seconds      Memory Limit: 65536 KB

The image stored on a computer can be represented as a matrix of pixels. In the RGB (Red-Green-Blue) color system, a pixel can be described as a triplex integer numbers. That is, the color of a pixel is in the format "r g b" where r, g and b are integers ranging from 0 to 255(inclusive) which represent the Red, Green and Blue level of that pixel.

Sometimes however, we may need a gray picture instead of a colorful one. One of the simplest way to transform a RGB picture into gray: for each pixel, we set the Red, Green and Blue level to a same value which is usually the average of the Red, Green and Blue level of that pixel (that is (r + g + b)/3, here we assume that the sum of r, g and b is always dividable by 3).

You decide to write a program to test the effectiveness of this method.

Input

The input contains multiple test cases!

Each test case begins with two integer numbers N and M (1 <= NM <= 100) meaning the height and width of the picture, then three N * M matrices follow; respectively represent the Red, Green and Blue level of each pixel.

A line with N = 0 and M = 0 signals the end of the input, which should not be proceed.

Output

For each test case, output "Case #:" first. "#" is the number of the case, which starts from 1. Then output a matrix of N * M integers which describe the gray levels of the pixels in the resultant grayed picture. There should be N lines with M integers separated by a comma.

Sample Input

2 2
1 4
6 9
2 5
7 10
3 6
8 11
2 3
0 1 2
3 4 2
0 1 2
3 4 3
0 1 2
3 4 4
0 0

Sample Output

Case 1:
2,5
7,10
Case 2:
0,1,2
3,4,3

 #include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int main(){
vector<int> r, g, b;
int n, m, test = , i, t;
while(cin >> n >> m){
if(n == && m == )
break;
test++;
r.clear();
g.clear();
b.clear();
for(i = ; i < n * m; i++){
cin >> t;
r.push_back(t);
}
for(i = ; i < n * m; i++){
cin >> t;
g.push_back(t);
}
for(i = ; i < n * m; i++){
cin >> t;
b.push_back(t);
}
cout << "Case " << test << ":" << endl;
for(i = ; i < n * m; i++){
cout << (r[i] + g[i] + b[i]) / ;
if((i + ) % m == )
cout << endl;
else
cout << ",";
}
}
//system("pause");
return ;
}

zoj 2857 Image Transformation的更多相关文章

  1. ZOJ 2671 Cryptography 矩阵乘法+线段树

    B - Cryptography Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Subm ...

  2. (七)Transformation和action详解-Java&Python版Spark

    Transformation和action详解 视频教程: 1.优酷 2.YouTube 什么是算子 算子是RDD中定义的函数,可以对RDD中的数据进行转换和操作. 算子分类: 具体: 1.Value ...

  3. ZOJ People Counting

    第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ  3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...

  4. ZOJ 3686 A Simple Tree Problem

    A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each no ...

  5. 线性分式变换(linear fractional transformation)

    线性分式变换(linear fractional transformation)的名称来源于其定义的形式:(ax+b)/(cx+d),其中分子分母是线性的,然后最外层是一个分式形式,所以叫做这个名字, ...

  6. OLE DB Command transformation 用法

    OLE DB Command transformation component 能够引用参数,逐行调用sqlcommand,This transformation is typically used ...

  7. OpenCASCADE General Transformation

    OpenCASCADE General Transformation eryar@163.com Abstract. OpenCASCADE provides a general transforma ...

  8. ZOJ Problem Set - 1394 Polar Explorer

    这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...

  9. ZOJ Problem Set - 1392 The Hardest Problem Ever

    放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵...今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题: #include <std ...

随机推荐

  1. 微信小程序消息推送,前端操作

    <form bindsubmit="getFormId" report-submit="true"> <button form-type=&q ...

  2. 阿里Canal框架(数据同步中间件)初步实践

    最近在工作中需要处理一些大数据量同步的场景,正好运用到了canal这款数据库中间件,因此特意花了点时间来进行该中间件的的学习和总结. 背景介绍 早期,阿里巴巴B2B公司因为存在杭州和美国双机房部署,存 ...

  3. java设计模式之单例设计模式

    单例设计模式 保证一个类在使用过程中,只有一个实例.优势就是他的作用,这个类永远只有一个实例. 优势:这个类永远只有一个实例,占用内存少,有利于Java垃圾回收. 单例设计模式关键点 私有的构造方法. ...

  4. a=a+b与a+=b的区别

    在一次工作中身边的一位资深的同事突然问了个a=a+b与a+=b有什么区别 此时有点尴尬了 不知道是真的不知道咧还是别有用意....今天抽点时间针对此问题做个小总结 一.性能方面 a=a+b是加法运算 ...

  5. P3368 【模板】树状数组 2 单点查询与区间修改

    题目描述 如题,已知一个数列,你需要进行下面两种操作: 1.将某区间每一个数数加上x 2.求出某一个数的和 输入输出格式 输入格式: 第一行包含两个整数N.M,分别表示该数列数字的个数和操作的总个数. ...

  6. 学习Python的day1

    自己以前从来没有写博客的想法,但是学Python,里面的老师也说了,写博客可以加深自己的记忆,也能回顾内容.还能给别人参考.挺值的.2017-09-16 一. Python介绍 python的创始人为 ...

  7. Ubuntu docker 使用命令 系列二

    1.下载官方远程仓下的镜像:sudo docker pull <docker 镜像> ,sudo docker pull centos (没有指定版本,就是下载的最新的os) 2. 下载某 ...

  8. 《深入理解Java虚拟机》读书笔记

    堆分配参数: -XX:+PrintGC 使用该参数,虚拟机启动后,只要遇到GC就会打印日志: -XX:+UseSerialGC 配置串行回收器: -XX:+PrintGCDeltails 可以查看详细 ...

  9. LR 两种录制:html与url

    一直在使用LR,对于Html_based script和Url-based script 两种录制方式之间,要如何选择,仍是一知半解.最近测试时遇到同样的业务功能,两种录制方式的脚本,单次执行时间差别 ...

  10. 面向对象的设计的SOLID原则

    S.O.L.I.D是面向对象设计和编程中5个重要编码规则的首字母的缩写. - SRP The Single Responsibility Principle 单一责任原则 当需要修改某个类的时候原因有 ...