码迷,mamicode.com
首页 > 其他好文 > 详细

PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642

时间:2021-04-05 12:15:31      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:ber   十进制   people   ast   sed   output   git   ati   middle   

PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642

题目描述:

People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for Red, the middle 2 digits for Green, and the last 2 digits for Blue. The only difference is that they use radix 13 (0-9 and A-C) instead of 16. Now given a color in three decimal numbers (each between 0 and 168), you are supposed to output their Mars RGB values.

译:火星上的人们在电脑中表示颜色和地球人用相似的方式。那就是 颜色用一个6 位数表示,前 2 位表示红色,中间 2 位表示绿色,最后 2 位表示蓝色。 唯一的不同是,他们(火星人)使用 13 进制 (0-9 和 A-C) 而不是 16 进制。现在给你一个三个十进制数(在 0 - 168 之间)表示颜色,你应该输出火星上的 RGB 值。


Input Specification (输入说明):

Each input file contains one test case which occupies a line containing the three decimal color values.

译:每个输入文件包含一个测试用例,每个用例在一行中包含三个十进制颜色的值。


Output Specification (输出说明):

For each test case you should output the Mars RGB value in the following format: first output #, then followed by a 6-digit number where all the English characters must be upper-cased. If a single color is only 1-digit long, you must print a 0 to its left.

译:对于每个测试用例你应该用接下来的格式输出火星上的 RGB 值:首先输出 # 然后接着输出一个所有英文字符必须大写的 6 位数字。如果单个颜色只有 1 位数,你必须在它左边输出一个 0


Sample Input (样例输入):

15 43 71

Sample Output (样例输出):

#123456

The Idea:

直接干!最简单的题!!! 没有之一!!!


The Codes:

#include<bits/stdc++.h>
using namespace std ;
string str = "0123456789ABC" , ans = "#" ;
int main(){
	int r , g , b ;
	cin >> r >> g >> b ;
	ans += str[r / 13] ; 	// 颜色第一位
	ans += str[r % 13] ;	// 颜色第二位
	ans += str[g / 13] ;
	ans += str[g % 13] ;
	ans += str[b / 13] ;
	ans += str[b % 13] ;
	cout<< ans << endl ;
	return 0 ;
}

PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642

标签:ber   十进制   people   ast   sed   output   git   ati   middle   

原文地址:https://www.cnblogs.com/lingchen1642/p/14612897.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!