zoj 2857 Image Transformation
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 <= N, M <= 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的更多相关文章
- ZOJ 2671 Cryptography 矩阵乘法+线段树
B - Cryptography Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Subm ...
- (七)Transformation和action详解-Java&Python版Spark
Transformation和action详解 视频教程: 1.优酷 2.YouTube 什么是算子 算子是RDD中定义的函数,可以对RDD中的数据进行转换和操作. 算子分类: 具体: 1.Value ...
- ZOJ People Counting
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ 3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...
- ZOJ 3686 A Simple Tree Problem
A Simple Tree Problem Time Limit: 3 Seconds Memory Limit: 65536 KB Given a rooted tree, each no ...
- 线性分式变换(linear fractional transformation)
线性分式变换(linear fractional transformation)的名称来源于其定义的形式:(ax+b)/(cx+d),其中分子分母是线性的,然后最外层是一个分式形式,所以叫做这个名字, ...
- OLE DB Command transformation 用法
OLE DB Command transformation component 能够引用参数,逐行调用sqlcommand,This transformation is typically used ...
- OpenCASCADE General Transformation
OpenCASCADE General Transformation eryar@163.com Abstract. OpenCASCADE provides a general transforma ...
- ZOJ Problem Set - 1394 Polar Explorer
这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...
- ZOJ Problem Set - 1392 The Hardest Problem Ever
放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵...今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题: #include <std ...
随机推荐
- 寻找项目中顶级Vue对象 (一)
个人博客首发博客园: http://www.cnblogs.com/zhangrunhao/ 参考 感谢作者 从一个奇怪的错误出发理解 Vue 基本概念 安装 - Vue.js 渲染函数 - Vue. ...
- JAVA平台的理解
主题: JAVA是解释执行还是编译执行? 我的答案 : 混合模式 闲谈 : 1. JAVA(write once,run anywhere): 2. GC(Garbagae Collection), ...
- 06.NopCommerce配置邮箱账户
NopCommerce如果配置让用户注册为通过邮箱注册,并且注册后激活邮箱才可登录,那么我们需要对NopCommerce的邮箱账户进行配置,用来发送邮件用.当然邮件还有很多其他用途,比如发送用户订阅的 ...
- P1116 车厢重组
题目描述 在一个旧式的火车站旁边有一座桥,其桥面可以绕河中心的桥墩水平旋转.一个车站的职工发现桥的长度最多能容纳两节车厢,如果将桥旋转180度,则可以把相邻两节车厢的位置交换,用这种方法可以重新排列车 ...
- hdu4003/蓝桥杯 金属采集
思路: 树形dp + 分组背包dp. 参考https://www.cnblogs.com/kuangbin/archive/2012/08/29/2661928.html 实现: #include & ...
- leetcode410 Split Array Largest Sum
思路: dp. 实现: class Solution { public: int splitArray(vector<int>& nums, int m) { int n = nu ...
- elasticsearch 2.4.0安装说明
首先从官网下载安装包,是个压缩文件,然后解压 在es目录下找到es的配置文件 修改集群(cluster)名称 PS:一般情况下一台机只部署一个es程序,也就是一个集群,默认集群名是ewater_mai ...
- HTTP协议 处理流程
我们平时在浏览网页的时候都是使用浏览器,输入你要的网址后回车,就会显示出我们所想要的内容,看似这个简单的用户操作行为的背后,Web的工作原理是怎样的呢?到底隐藏了些什么呢? 对于传统的上网流程,系统它 ...
- IE8 window.open 不支持此接口 的问题解决
在使用vs2010调试代码时,突然出现 window.open 不支持此接口的提示,开始认为是不是vs的问题,后来上网查询说是系统问题.我不想重装系统,之后发现是IE的问题,使用其他浏览器浏览系统不会 ...
- (转)使用Spring配置文件实现事务管理
http://blog.csdn.net/yerenyuan_pku/article/details/52886207 前面我们讲解了使用Spring注解方式来管理事务,现在我们就来学习使用Sprin ...