进制类问题
26进制,提醒我去刷类似的题
找一下规律:
A:1 * 1
B:2 * 1
AA:1 * 1 + 1 * 26
AB:2 * 1 + 1 * 26
AAA:1 * 1 + 1 * 26 + 1 * 26 * 26
BBA: 1 * 1 + 2 * 26 + 2 * 26 * 26
#include<iostream>
#include<algorithm>
#include<cstring>
#include<iomanip>
#include<vector>
#include<cmath>
#include<cctype>
#define IOS std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
#define pi acos(-1);
#include<map>
using namespace std;
typedef struct node{
}node;
typedef long long ll;
string s;
ll ans;
void ccin(){
cin>>s;
}
void work(){
for(auto ss: s){
ans*=26;
ans+=ss-'A'+1;
}
cout<<ans;
}
int main(){
IOS;
ccin();
work();
return 0;
}
该代码片段展示了一个C++程序,用于处理27进制的数字转换。输入是一个字母数字字符串,程序将其转换为26进制表示并输出结果。主要涉及字符串操作和数学计算。
960

被折叠的 条评论
为什么被折叠?



