题目 题意: 给定一个数或者大写字母组成的字符串,相互转换。转换规则参考了Excel表,A-Z为1-26,AA、AB、AZ为27,28,29… 思路: 十进制和26进制互相转换就行。但是注意10进制转26进制要记得每次除之前要–,因为A实际对应1,你需要用%的余数+‘A’-1,如果余数是0呢,就会出现非大写字母,那肯定寄了。反正感觉怪怪的。 时间复杂度: O(n) 代码:
#include
using namespace std;
const int N = 1e5+10;
typedef pair PII;
int n,m,k,T;
templatevoid write(T &x)
{
if(x 9) write(x/10);
putchar('0'+x%10);
}
templatevoid read(T &x)
{
char ch = getchar(); T f = 1; x = 0;
while(!isdigit(ch)) {if(ch=='-') f*=-1; ch = getchar();}
while(isdigit(ch)) {x = x*10 + ch-48; ch = getchar();}
x *= f;
}
void solve()
{
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
string s;
while(cin>>s,s!="#")
{
if(s[0]>='0'&&s[0]
关注
打赏