PAT甲级——A1027 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 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.
Sample Input:
15 43 71
Sample Output:
#123456
只能说巨简单!
#include <iostream>
#include <string>
using namespace std;
int main()
{
int a[];
string str = "0123456789ABC";
cin >> a[] >> a[] >> a[];
printf("#%c%c%c%c%c%c\n", str[a[] / ], str[a[] % ],
str[a[] / ], str[a[] % ], str[a[] / ], str[a[] % ]);
return ;
}
PAT甲级——A1027 Colors in Mars的更多相关文章
- PAT 甲级 1027 Colors in Mars (20 分)
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way a ...
- PAT 甲级 1027 Colors in Mars (20 分)(简单,进制转换)
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way ...
- PAT甲级——1027 Colors in Mars
1027 Colors in Mars People in Mars represent the colors in their computers in a similar way as the E ...
- PAT 甲级 1027 Colors in Mars
https://pintia.cn/problem-sets/994805342720868352/problems/994805470349344768 People in Mars represe ...
- A1027 Colors in Mars (20)(20 分)
A1027 Colors in Mars (20)(20 分) People in Mars represent the colors in their computers in a similar ...
- PAT A1027 Colors in Mars (20)
AC代码 #include <cstdio> const int max_n = 1000; int ans[max_n]; char result[max_n]; char radix[ ...
- A1027. Colors in Mars
People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...
- PAT Advanced 1027 Colors in Mars (20 分)
People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...
- PAT 甲级 1044 Shopping in Mars
https://pintia.cn/problem-sets/994805342720868352/problems/994805439202443264 Shopping in Mars is qu ...
随机推荐
- 如何查看redis占用内存大小
redis缓存固然高效,可是它会占用我们系统中宝贵的内存资源,特别是当我们的项目运行了一段时间后,我们需要看一下redis占用了多少内存,那么可以用“info”命令查看. 执行info命令后,找到Me ...
- iOS开发UITableView随笔
1.设置cell的间隔 - (void)setFrame:(CGRect)frame{ frame.size.height -=; [super setFrame:frame]; } 2.刷新row或 ...
- CSS 常用的兼容性调试技巧
1.实现所有浏览器主页居中 Firefox下主页居中代码:.box{margin:0px auto} IE5.5下主页居中代码:body{text-align:center;} 将以上两种代码,合在一 ...
- 16-1-es5
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- NoSQL SimpleDB
- AWS云管理平台
- python csv write 乱码
参考 : https://www.zhihu.com/question/34201726 1.使用utf_8_sig with open('d:/file.csv', 'w', encoding='u ...
- MVVM test
示例代码 public class RegisterUserViewModel { public UserInfo userInfo { get; set; } public ICommand Cli ...
- SQLServer中使用索引视图
在SQL Server中,视图是一个保存的T-SQL查询.视图定义由SQL Server保存,以便它能够用作一个虚拟表来简化查询,并给基表增加另一层安全.但是,它并不占用数据库的任何空间.实际上,在你 ...
- nginx 解决问题