CodeForces - 1B Spreadsheets 模拟
程序员文章站
2022-05-09 16:25:23
...
题意:
有两种形式的字符串可以相互转换,给你其中的一种,让你转换为另一种。
R23C55 ---> BC23
BC23 ---> R23C55 A为1,AA为27
思路:
利用 sscanf 转换
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int maxn = 1e6+10;
char s[maxn],str[maxn];
void prin(int y)
{
if(!y)
return ;
prin( (y-1)/26 );
putchar( ((y-1)%26)+'A' );
}
int main()
{
int n;
int x,y;
scanf("%d",&n);
while(n--)
{
scanf("%s",s);
if(sscanf(s,"R%dC%d",&x,&y)==2)
{
prin(y);
printf("%d\n",x);
}
else
{
y = 0;
sscanf(s,"%[A-Z]%d",str,&x);
int len = strlen(str);
for(int i=0;i<len;i++)
{
y = y*26+str[i]-'A'+1;
}
printf("R%dC%d\n",x,y);
}
}
return 0;
}
上一篇: 晚清名臣李鸿章的母亲是谁?李鸿章父母竟然是兄妹恋?
下一篇: webpack+vue路由
推荐阅读
-
CodeForces - [ACM-ICPC Jiaozuo Onsite A]Xu Xiake in Henan Province(模拟)
-
Codeforces Round #533 (Div. 2) D. Kilani and the Game(bfs+模拟)
-
codeforces 1375D 模拟+思维
-
Codeforces Round #258 (Div. 2) B. Sort the Array (模拟)
-
Codeforces Round #256 (Div. 2) B. Suffix Structures(模拟)_html/css_WEB-ITnose
-
B. Nastya Is Playing Computer Games---(水题模拟)Codeforces Round #546 (Div. 2)
-
B. Two Arrays(模拟+思维)Codeforces Round #673 (Div. 2)
-
B. Disturbed People(模拟) Codeforces Round #521 (Div. 3)
-
D. Sequence and Swaps(模拟+枚举) Educational Codeforces Round 99 (Rated for Div. 2)
-
CodeForces - 1256B Minimize the Permutation(思维模拟)