王八变成汤 2021-11-26 18:45 采纳率: 0%
浏览 15
已结题

不知道 为什么有个样例过不去

https://vjudge.net/problem/CodeForces-1B
In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is used. The first column has number A, the second — number B, etc. till column 26 that is marked by Z. Then there are two-letter numbers: column 27 has number AA, 28 — AB, column 52 is marked by AZ. After ZZ there follow three-letter numbers, etc.

The rows are marked by integer numbers starting with 1. The cell name is the concatenation of the column and the row numbers. For example, BC23 is the name for the cell that is in column 55, row 23.

Sometimes another numeration system is used: RXCY, where X and Y are integer numbers, showing the column and the row numbers respectfully. For instance, R23C55 is the cell from the previous example.

Your task is to write a program that reads the given sequence of cell coordinates and produce each item written according to the rules of another numeration system.

Input
The first line of the input contains integer number n (1 ≤ n ≤ 105), the number of coordinates in the test. Then there follow n lines, each of them contains coordinates. All the coordinates are correct, there are no cells with the column and/or the row numbers larger than 106 .

Output
Write n lines, each line should contain a cell coordinates in the other numeration system.

Examples
Input
2
R23C55
BC23
Output
BC23
R23C55


#include<stdio.h>
#include<string.h>
typedef long long ll;
const int N=1e6+10;
ll t,l,f[N];
char s[N];
int main()
{
    scanf("%lld",&t);
    while(t--)
    {
        memset(s,0,sizeof(s));
        scanf("%s",s);
        l=strlen(s);
        memset(f,0,sizeof(f));
        ll i=0,tot=0;
        while(s[i]>='A'&&s[i]<='Z') i++;
        while(s[i]>='0'&&s[i]<='9') i++;
        if(i<l){
            ll x=0,j,y=0,z;
            for(j=1;s[j]>='0'&&s[j]<='9';j++)
                x=x*10+(s[j]-'0');
            for(j=++j;j<l;j++)
                y=y*10+s[j]-'0';
            while(y>0){
                z=y%26;
                f[tot++]=z;
                y=(y-z)/26;
            }
            for(int i=tot-1;i>=0;i--)
                printf("%c",f[i]+'A'-1);
            printf("%lld\n",x);
        }else{
            ll x=0,y=0,z,j;
            for(j=0;s[j]>='A'&&s[j]<='Z';j++)
                x=x*26+s[j]-'A'+1;
            for(;j<l;j++)
            y=y*10+s[j]-'0';
            printf("R%lldC%lld\n",y,x);
        }
     }
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 12月4日
    • 创建了问题 11月26日

    悬赏问题

    • ¥20 Wpf Datarid单元格闪烁效果的实现
    • ¥15 图像分割、图像边缘提取
    • ¥15 sqlserver执行存储过程报错
    • ¥100 nuxt、uniapp、ruoyi-vue 相关发布问题
    • ¥15 浮窗和全屏应用同时存在,全屏应用输入法无法弹出
    • ¥100 matlab2009 32位一直初始化
    • ¥15 Expected type 'str | PathLike[str]…… bytes' instead
    • ¥15 三极管电路求解,已知电阻电压和三级关放大倍数
    • ¥15 ADS时域 连续相位观察方法
    • ¥15 Opencv配置出错