题意
给出3个10进制的数,转换为13进制按照规则输出。
主要是进制转换这个知识点。
input:
15 43 71
output:
#123456
#pragma GCC optimize(2)
#include"bits/stdc++.h"
using namespace std;
string solve(int x) {
string s;
while (x) {
int t = x % 13;
if (t > 10) s.push_back('A' + t - 10);
else s.push_back('0' + t);
x /= 13;
}
if (s.size() < 2) s.push_back('0');
reverse(s.begin(),s.end());
return s;
}
int main() {
//freopen("input.txt", "r", stdin);
printf("#");
for (int i = 0; i < 3; ++i) {
int x;
cin >> x;
cout << solve(x);
}
}