javaee论坛

普通会员

225648

帖子

335

回复

349

积分

楼主
发表于 2019-11-03 09:06:31 | 查看: 110 | 回复: 2

PeopleinMarsrepresentthecolorsintheircomputersinasimilarwayastheEarthpeople.Thatis,acolorisrepresentedbya6-digitnumber,wherethefirst2digitsarefor Red,themiddle2digitsfor Green,andthelast2digitsfor Blue.Theonlydifferenceisthattheyuseradix13(0-9andA-C)insteadof16.Nowgivenacolorinthreedecimalnumbers(eachbetween0and168),youaresupposedtooutputtheirMarsRGBvalues.

InputSpecification:

Eachinputfilecontainsonetestcasewhichoccupiesalinecontainingthethreedecimalcolorvalues.

OutputSpecification:

ForeachtestcaseyoushouldoutputtheMarsRGBvalueinthefollowingformat:firstoutput #,thenfollowedbya6-digitnumberwherealltheEnglishcharactersmustbeupper-cased.Ifasinglecolorisonly1-digitlong,youmustprinta 0 toitsleft.

SampleInput:154371SampleOutput:#123456#include<iostream>#include<string>#include<sstream>#include<vector>#include<algorithm>#include<cmath>usingnamespacestd;//9:57intmain(){//freopen("C:\\Users\\chenzhuo\\Desktop\\in.txt","r",stdin);inta[3];cin>>a[0]>>a[1]>>a[2];chartmp[]={'0','1','2','3','4','5','6','7','8','9','A','B','C'};cout<<'#';stringa1[3]={"","",""};for(inti=0;i<3;i++){do{chark=tmp[a[i]%13];a1[i]=k+a1[i];a[i]/=13;}while(a[i]>0);}for(inti=0;i<3;i++){if(a1[i].size()==1)a1[i]='0'+a1[i];cout<<a1[i];}}

 


普通会员

2

帖子

340

回复

352

积分
沙发
发表于 2022-12-24 23:34:23

不错

普通会员

10

帖子

299

回复

330

积分
板凳
发表于 2024-03-28 04:13:16

如果你智商能再高点,也许我会上当

您需要登录后才可以回帖 登录 | 立即注册

触屏版| 电脑版

技术支持 历史网 V2.0 © 2016-2017