zoukankan      html  css  js  c++  java
  • B. Spreadsheets

    B. Spreadsheets

    #include<bits/stdc++.h>
    using namespace std;
    const int maxn=1e6+10;
    #define ll long long
    char a[maxn];
    int temp[maxn];
    char zimu[maxn],shuzi[maxn];
    int main()
    {
        int t;
        scanf("%d",&t);
        while(t--)
        {
            ll r,c;
            scanf("%s",a);
            if(sscanf(a,"R%lldC%lld",&r,&c)==2)
            {
                int cnt=0;
                while(c!=0)
                {
                    temp[++cnt]=(c-1)%26;
                    c=(c-1)/26;
                }
                for(int i=cnt; i>=1; i--)
                    printf("%c",'A'+temp[i]);
                printf("%lld
    ",r);
            }
            else
            {
                int len=strlen(a);
                int cnt1,cnt2;
                cnt1=cnt2=0;
                for(int i=0; i<len; i++)
                {
                    if(a[i]<='Z'&&a[i]>='A')
                        zimu[++cnt1]=a[i];
                    else
                        shuzi[++cnt2]=a[i];
                }
                shuzi[++cnt2]='';
                printf("R%sC",shuzi+1);
                ll num=0;
                for(int i=1; i<=cnt1; i++)
                {
                    num=num+zimu[i]-'A'+1;
    //                printf("zimu%d
    ",zimu[i]-'A'+1);
                    num=num*26;
                }
                num/=26;
                printf("%lld
    ",num);
            }
        }
    }
  • 相关阅读:
    codeforces 671C
    zoj3256
    hit2739
    hdu5737
    2017.1其他简要题解
    hdu5967
    初探插头dp
    11月下旬题解
    CompletableFuture的get和getNow()的区别
    python 镜像
  • 原文地址:https://www.cnblogs.com/dongdong25800/p/11139571.html
Copyright © 2011-2022 走看看