﻿PAT(A) 1027. Colors in Mars (20)-Ocrosoft

PAT(A) 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

Each input file contains one test case which occupies a line containing the three decimal color values.

Output

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 the left.

Sample Input

```15 43 71
```

Sample Output

```#123456
```

```#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cctype>
#include <climits>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
#define strend string::npos
#define ms(a) memset(a,0,sizeof(a))
#define rep(a,v,b) for(int a=v;a<b;a++)
#define repe(a,v,b) for(int a=v;a<=b;a++)
#define pre(a,v,b) for(int a=v;a>b;a--)
#define pree(a,v,b) for(int a=v;a>=b;a--)
#define lowbit(x) x&-x
typedef long long LL;
const LL LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const int MAXN = 27 + 10;
const int MOD = 1000000007;
int gcd(int a, int b)
{
if (!b)return a;
return gcd(b, a%b);
}
/*(◕‿‿◕) (◕‿‿◕) (◕‿‿◕) (◕‿‿◕) (◕‿‿◕)*/
/*(◕‿‿◕) 跟我签订契约，成为马猴烧酒吧! (◕‿‿◕)*/
/*(◕‿‿◕) (◕‿‿◕) (◕‿‿◕) (◕‿‿◕) (◕‿‿◕)*/
using namespace std;
int main()
{
int a,b,c;
int d=13;
cin>>a>>b>>c;
vector<int> aa,bb,cc;
do
{
aa.push_back(a%d);
a/=d;
}while(a);
do
{
bb.push_back(b%d);
b/=d;
}while(b);
do
{
cc.push_back(c%d);
c/=d;
}while(c);
printf("#");
if(aa.size()==1)printf("0");
for(int i=aa.size()-1;i>=0;i--)
{
if(aa[i]<10)printf("%d",aa[i]);
else if(aa[i]==10)printf("A");
else if(aa[i]==11)printf("B");
else if(aa[i]==12)printf("C");
else if(aa[i]==13)printf("D");
else if(aa[i]==14)printf("E");
else if(aa[i]==15)printf("F");
}
if(bb.size()==1)printf("0");
for(int i=bb.size()-1;i>=0;i--)
{
if(bb[i]<10)printf("%d",bb[i]);
else if(bb[i]==10)printf("A");
else if(bb[i]==11)printf("B");
else if(bb[i]==12)printf("C");
else if(bb[i]==13)printf("D");
else if(bb[i]==14)printf("E");
else if(bb[i]==15)printf("F");
}
if(cc.size()==1)printf("0");
for(int i=cc.size()-1;i>=0;i--)
{
if(cc[i]<10)printf("%d",cc[i]);
else if(cc[i]==10)printf("A");
else if(cc[i]==11)printf("B");
else if(cc[i]==12)printf("C");
else if(cc[i]==13)printf("D");
else if(cc[i]==14)printf("E");
else if(cc[i]==15)printf("F");
}
printf("\n");
return 0;
}  ```