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 ...
随机推荐
- SyncDictionary
using System; using System.Collections; using System.Collections.Generic; using System.Threading; us ...
- _event_active
EventId 事件ID GUID 对应creature或gameobject表中 guid,正数为生物,负数为物体 ActiveFlag 生物或物体激活时的flag,通常为0 NoticeText ...
- Flexbox弹性布局,更优雅的布局
Flexbox,更优雅的布局 Flex 布局教程:语法篇 Flex 布局教程:实例篇 2009年,W3C提出了一种新的方案----Flex布局,可以简便.完整.响应式地实现各种页面布局.目前,它已经得 ...
- Bootstrap & Font Awesome 学习笔记
学习网站:http://bootstrap.ninghao.net/index.html https://www.freecodecamp.cn http://www.runoob.com/boots ...
- SQLServer 中的存储过程中判断临时表是否存在,存在则删除临时表
IF OBJECT_ID('TEMPDB..#BCROSSREFERENCE ') IS NOT NULL DROP TABLE #BCROSSREFERENCE IF OBJECT_ID('TEMP ...
- Event(事件)
1.ZC:之前一直没怎么用过 OpenEvent(...),这次试用居然老是报错... 弄了一下,貌似是 OpenEvent(...)的第一个参数设置成0了... FhEvent_Communicat ...
- 学习笔记45—Linux压缩集
1.压缩功能 安装 sudo apt-get install rar 卸载 sudo apt-get remove rar 2.解压功能 安装 sudo apt-get install unrar 卸 ...
- from import
from A import B # 只导入A里面的B
- java再次学习
1.maven配置.
- Asp.net core 学习笔记 ( OData )
2018-12-10 更新 : 从前我都是把 entity 直接用于 odata 曝露 api 给程序用. 如果这个程序是我们自己写的前端,这样的方式非常好,因为就好比前端可以直接对数据库每一个表做操 ...