1027 Colors in Mars (20 分)
 

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.

题意:

三个数分别转十三进制

AC代码:

#include <iostream>
using namespace std;
int main(){
char ans[];
for(int i=;i<;i++) ans[i]=i+'';
ans[]='A',ans[]='B',ans[]='C';
int a[];
for(int i=;i<;i++) cin>>a[i];
cout<<"#";
for(int i=;i<;i++){
cout<<ans[a[i]/]<<ans[a[i]%];
}
return ;
}
#include<bits/stdc++.h>
using namespace std;
char d[]={'','','','','','','','','','','A','B','C'};
int main(){
int a[];
cin>>a[]>>a[]>>a[];
cout<<"#";
for(int i=;i<=;i++)
{
int x=a[i];
int b[];
int k=;
//转成13进制
while(x>=){
b[++k] = x/;
x=x%;
}
b[++k]=x;
if(k==){
cout<<<<d[b[]];
}else{
cout<<d[b[]]<<d[b[]];
}
}
return ;
}

PAT 甲级 1027 Colors in Mars (20 分)(简单,进制转换)的更多相关文章

  1. 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 ...

  2. PAT1027 Colors in Mars (20分) 10进制转13进制

    题目 People in Mars represent the colors in their computers in a similar way as the Earth people. That ...

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

    PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642 题目描述: People in Mars represent the c ...

  4. 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 ...

  5. PAT (Advanced Level) Practice 1027 Colors in Mars (20 分)

    People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...

  6. 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 ...

  7. PAT 甲级 1144 The Missing Number (20 分)(简单,最后一个测试点没过由于开的数组没必要大于N)

    1144 The Missing Number (20 分)   Given N integers, you are supposed to find the smallest positive in ...

  8. PAT 甲级 1015 Reversible Primes (20 分) (进制转换和素数判断(错因为忘了=))

    1015 Reversible Primes (20 分)   A reversible prime in any number system is a prime whose "rever ...

  9. 【PAT甲级】1027 Colors in Mars (20 分)

    题意: 输入三个范围为0~168的整数,将它们从十三进制转化为十进制然后前缀#输出. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include& ...

随机推荐

  1. iframe中的target属性

    在使用iframe的时候,我们有时候会遇到,外面的链接,去操作iframe中的页面 <!DOCTYPE html> <html> <head> <meta c ...

  2. Pandas-Numpy-Scipy-Matplotlib

    Ref:Using iloc, loc, & ix to select rows and columns in Pandas DataFrames 单纯的方括号只有两个用途:基于列的label ...

  3. vue 项目中使用postMessage问题总结

    问题描述: 由于目前做的项目分成两个项目,通过iframe嵌套,所以用到了 postMessage 当监听传过来的值的时候  出现了接受多次的问题 产生原因: 我的监听事件是放在home页 mount ...

  4. Charles----伪造手机端的request和reponse参数

    使用场景: 在测试中通过伪造reponse数据来模拟某些测试场景,如下截图.要求:通过修改reponse中的值,再次请求修改7为100,只是会显示为99+ 实现方式: 1.通过breakpoints来 ...

  5. jaxb生成cdata块

    1.需要添加一个适配器: import javax.xml.bind.annotation.adapters.XmlAdapter; public class AdapterCDATA extends ...

  6. 关于pageHelper无法查到总数踩到的坑

    问题代码 PageHelper.startPage(pageNum,pageSize); List<pojoVo> pojoVo=robotService.getPageList(); P ...

  7. mysql 解决忘记密码 mysql5.7 远程登录不上MySQL(解决腾讯服务器初始mysql密码问题)

    一.修改MySQL启动配置文件 #如果不知道配置文件,先查找find / -name my.cnf#编辑配置文件 vim /etc/my.cnf 在[mysql]  下面第一行加入 skip-gran ...

  8. linux mint 19 打开 Windows 下制作的 TXT 文件时‘乱码’

    因为 Linux 采用的是 UTF-8 编码,Windows 的中文编码是 GB18030. 解决的办法:让 Linux 的文本编辑器支持 GB18030 1.我们安装一个小软件"Dconf ...

  9. pycharm 头模板

    #!/usr/local/bin/python3 # -*- coding: utf-8 -*- """ @author: Ray @contact: raylively ...

  10. Luogu P2151 [SDOI2009]HH去散步 矩乘加速DP

    思路:矩乘优化DP 提交:3次(用了一个奇怪的东西导致常数过大) 题解: 如果可以走完正向边后又走反向边那就显然了,但是不能走,所以我们要将正反向边分别编号,区分正反向边. 所以这道题的矩阵是以边的编 ...