• CF1B Spreadsheets


    【题解】

      模拟就行,类似进制转换

     1 #include<cstdio>
     2 #include<algorithm>
     3 #include<cstring>
     4 #define N 200010
     5 #define rg register
     6 using namespace std;
     7 int n,m,l1,l2,pos,a[N],top;
     8 char s[N],s1[N];
     9 inline int read(){
    10     int k=0; char c=getchar();
    11     while(c<'0'||c>'9')c=getchar();
    12     while('0'<=c&&c<='9')k=k*10+c-'0',c=getchar();
    13     return k;
    14 }
    15 inline void work(bool type){
    16     if(type==0){
    17         putchar('R');
    18         for(rg int i=pos;i<=n;i++) putchar(s[i]);
    19         putchar('C');
    20         int tmp=0;
    21         for(rg int i=1;i<pos;i++) tmp=tmp*26+s[i]-'A'+1;
    22         printf("%d
    ",tmp);
    23     }
    24     else{
    25         int pos2=pos;
    26         while(s[pos2]>='0'&&s[pos2]<='9') pos2++; pos2++;
    27         int t1=0,t2=0;
    28         for(rg int i=pos2;i<=n;i++)t1=t1*10+s[i]-'0';
    29         top=0;
    30         while(t1){
    31             a[++top]=t1%26;
    32             t1/=26;
    33         }
    34         for(rg int i=1;i<=top-1;i++) if(a[i]<=0)a[i+1]--,a[i]+=26;
    35         while(a[top]<=0) top--;
    36         for(rg int i=top;i;i--) printf("%c",(char)(a[i]+'A'-1));
    37         for(rg int i=pos;i<pos2-1;i++) putchar(s[i]);
    38         puts("");
    39     }
    40 }
    41 int main(){
    42     m=read();
    43     while(m--){
    44         scanf("%s",s+1);
    45         n=strlen(s+1);
    46         pos=1; bool type=0;
    47         while(s[pos]>='A'&&s[pos]<='Z')pos++;
    48         for(rg int i=pos;i<=n;i++) if(s[i]>='A'&&s[i]<='Z'){
    49             type=1; break;
    50         }
    51         work(type);
    52     }
    53     return 0;
    54 }
    View Code
  • 相关阅读:
    the Agiles Scrum Meeting 8
    the Agiles Scrum Meeting 7
    the Agiles Scrum Meeting 6
    项目使用说明——英文版
    第十次例会
    第九次例会
    第八次例会
    第六次例会
    第七次例会
    第五次例会
  • 原文地址:https://www.cnblogs.com/DriverLao/p/9052744.html
Copyright © 2020-2023  润新知