WA#6,求调,悬关

CF1B Spreadsheets

你的判断条件错了 你看看这组数据 ```c 1 RX251 ``` 正确答案是 $R251C492$ 你的答案是 $IQ$ 仔细看了一下是你的判断条件还不够完整 你只判断了第一位是 $R$ 且第二位不是 $C$ 我的方法是判断有没有字母前面是数字的 如果有数字就代表是行列式表达法 没有数字那么就是Excel表达法 希望能帮到你 下面是改完的程序 ```cpp #include<bits/stdc++.h> #define int long long using namespace std; int n; string s,t=" ABCDEFGHIJKLMNOPQRSTUVWXYZ"; string solve1(string s){ string res=""; int r=0,c=0,i=1; while(isdigit(s[i])){ r=r*10+s[i]-48; i++; } i++; while(isdigit(s[i])){ c=c*10+s[i]-48; i++; } while(r){ res=char(r%10+48)+res; r/=10; } while(c){ if(c%26==0){ res='Z'+res; c=c/26-1; } else{ res=t[c%26]+res; c/=26; } } return res; } string solve2(string s){ int i=0,ret=0; string tmp="",res="R"; while(isalpha(s[i])){ tmp+=s[i]; i++; } while(isdigit(s[i])){ res+=s[i]; i++; } res+='C'; for(int i=0;i<tmp.size();i++){ if(tmp[i]!='Z') ret+=t.find(tmp[i])*pow(26,tmp.size()-i-1); else ret+=26*pow(26,tmp.size()-1-i); } tmp=""; while(ret){ tmp+=ret%10+48; ret/=10; } reverse(tmp.begin(),tmp.end()); res+=tmp; return res; } signed main(){ cin>>n; while(n--){ cin>>s; bool flag=0;//0表示Excel法 1表示行列法 for(int i=1;i<s.size();i++) { if(s[i]>='A' and s[i]<'Z' and s[i-1]>='0' and s[i-1]<='9') { flag=1; } } if(flag) { cout<<solve1(s)<<endl; } else { cout<<solve2(s)<<endl; } } return 0; } ```
by LYRT_Subway @ 2024-03-19 20:22:26


@[LYRT_Subway](/user/577429) 万分感激!今天才看到,已关
by LALaker @ 2024-03-20 17:33:48


@[LALaker](/user/681941) 感谢支持
by LYRT_Subway @ 2024-03-21 16:02:48


|