PAT 1027 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<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define maxnum 100005 char s[] = {'A','B','C'}; int main(){ int a[];
for(int i=;i < ;i++) cin >> a[i];
cout << "#";
for(int i=;i < ;i++){
vector<char> vec;
if(a[i] == ){cout << "";continue;}
while(a[i]){
int num = a[i]%;
if(num < ){vec.push_back(num+'');}
else vec.push_back(s[num%]);
a[i] = a[i]/;
}
if(vec.size() == ) cout << ;
for(int i=vec.size()-;i >= ;i--){
cout << vec[i];
}
}
return ;
}
——再次注意0这个数据,在进制转换中一直会出。
PAT 1027 Colors in Mars的更多相关文章
- PAT 1027 Colors in Mars[简单][注意]
1027 Colors in Mars (20)(20 分) People in Mars represent the colors in their computers in a similar w ...
- pat 1027 Colors in Mars(20 分)
1027 Colors in Mars(20 分) People in Mars represent the colors in their computers in a similar way as ...
- 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 ...
- 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 ...
- 1027 Colors in Mars (20 分)
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way a ...
- PTA (Advanced Level) 1027 Colors in Mars
Colors in Mars People in Mars represent the colors in their computers in a similar way as the Earth ...
- 1027. Colors in Mars (20) PAT
题目:http://pat.zju.edu.cn/contests/pat-a-practise/1027 简单题,考察十进制数和n进制数的转换和输出格式的控制. People in Mars rep ...
随机推荐
- postgresql change table
--if cloumn exist SELECT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema='ent' A ...
- JavaScript——执行环境、变量对象、作用域链
前言 这几天在看<javascript高级程序设计>,看到执行环境和作用域链的时候,就有些模糊了.书中还是讲的不够具体.通过上网查资料,特来总结,以备回顾和修正. 目录: EC(执行环境或 ...
- 51nod 1215 数组的宽度(单调栈)
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1215 题意: 思路: 计算出以第i个数为最大值的区间范围,l_max[i ...
- python学习打卡 day07 set集合,深浅拷贝以及部分知识点补充
本节的主要内容: 基础数据类型补充 set集合 深浅拷贝 主要内容: 一.基础数据类型补充 字符串: li = ["李嘉诚", "麻花藤", "⻩海峰 ...
- 前端js实现 blob转base64位 和 base64位转blob
//**dataURL to blob** function dataURLtoBlob(dataurl) { var arr = dataurl.split(','), mime = arr[0]. ...
- C++使用thread类进行多线程编程
C++11中引入了一个用于多线程操作的thread类,简单多线程示例: #include <iostream> #include <thread> #include <W ...
- @Value("#{}")与@Value("${}")的区别以及用法
package com.ieou.capsule_basic_info.util; import org.springframework.beans.factory.annotation.Value; ...
- 如何连接oracle 12c可插拔数据库
启动根容器:[oracle@eric ~]$ export ORACLE_SID=cup[oracle@eric ~]$ sqlplus / as sysdbaSQL*Plus: Release 12 ...
- C++ Web 编程
C++ Web 编程 什么是 CGI? 公共网关接口(CGI),是一套标准,定义了信息是如何在 Web 服务器和客户端脚本之间进行交换的. CGI 规范目前是由 NCSA 维护的,NCSA 定义 CG ...
- 学习笔记39—笑谈FireFox标签不同步(IOS和Wiindows)
为了解决国内用户连接 全球同步服务器 困难的问题,火狐中国版推出了 全球服务 和 本地服务 两套服务. 这两套服务的账号和数据并不通用,并且只有中国版提供了切换功能,因此当你在同步过程中遇到“未知账号 ...