PAT甲级 1027
来源:互联网 发布:免费的起名软件 编辑:程序博客网 时间:2024/05/29 19:04
Colors in Mars
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.
Input
Each input file contains one test case which occupies a line containing the three decimal color values.
Output
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 the left.
Sample Input
15 43 71
Sample Output
#123456
考点
- 进制处理
题解
- 直接计算
#include<iostream>#include<stdio.h>#include<algorithm>using namespace std;void outputSingle(int n){ if(n>9)printf("%c",n-10+'A'); else printf("%d",n);}void output(int n){ int x=n/13,y=n%13; outputSingle(x); outputSingle(y);}int main(){ //freopen("./in","r",stdin); int r,g,b; scanf("%d %d %d",&r,&g,&b); printf("#"); output(r); output(g); output(b); return 0;}
- PAT(甲级)1027
- PAT甲级1027
- PAT甲级 1027
- pat 甲级 1027-1030
- PAT 甲级
- PAT 甲级 1027 Colors in Mars
- PAT甲级 A1025.PAT RANKING
- PAT 甲级 1025 PAT Ranking
- PAT(甲级)1003
- PAT(甲级)1004
- PAT(甲级)1005
- PAT(甲级)1006
- PAT(甲级)1007
- PAT(甲级)1008
- PAT(甲级)1009
- PAT(甲级)1010
- PAT(甲级)1011
- PAT(甲级)1012
- 2017.03.07 前端面试之阿里彩票
- CCF 历年真题之工资计算(_1612_2_WageCalculation.java)参考答案
- Java Web项目开发到底需要掌握哪些技术?
- Linux指令
- 【福利】哈佛大学公开课:构建动态网站
- PAT甲级 1027
- 统计中的三种相关系数及Matlab实现
- 一起学ROS之通信机制
- 十分钟成为 Contributor 系列 | 重构内建函数进度报告
- Django实现登录验证功能
- 使用gdb 查找运行的segmentation fault(core dumped)
- OOM killer问题
- Android学习(三)Button和imageButton
- jsp中的basePath和path (绝对路径 相对路径)