听灌多,求助
  • 板块灌水区
  • 楼主Quartz_Blocks
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/6/22 08:01
  • 上次更新2024/6/22 11:52:37
查看原帖
听灌多,求助
1059176
Quartz_Blocks楼主2024/6/22 08:01

WA on #6

CF1B

#include <bits/stdc++.h>
using namespace std;
int n;
int main(){
	cin >> n;
	while(n--){
		string s;
		cin >> s;
		if(s[0] == 'R' && s[1] <= '9' && s[1] >= '0'){
			int x = 0,y = 0;
			int i = 1;
			for(;s[i] <= '9' && s[i] >= '0';i++){
				x = x*10+int(s[i]-'0');
			}
			i++;
			int len = s.length();
			for(;i < len;i++){
				y = y*10+int(s[i]-'0');
			}
			string yy = "";
			while(y > 0){
                //cout << y << endl;
                if(y%26 == 0) yy += 'Z';
                
                else yy += char(y%26+64);
				y /= 26;
			}
			int len2 = yy.length();
			for(int i = len2-1;i >= 0;i--){
				cout << yy[i];
			}
			cout << x << endl;
		}else{
			string x = "";int y = 0,len;
			len = s.length();
			int i = 0;
			for(;s[i] <= 'Z' && s[i] >= 'A';i++){
 				x += s[i];
			}
			for(;i < len;i++){
				y = y*10+int(s[i]-'0');
			}
            int xx = 0; 
            int j = 0;
            for(int i = x.length()-1;i >= 0;i--,j++){
                xx += pow(26,j)*int(x[i]-'A'+1);
            }
			cout << 'R' << y << 'C' << xx << endl;
		}
	}
	return 0;
}
2024/6/22 08:01
加载中...