网站地图什么意思,门户网站cms程序,苍南具城乡建设局网站,蓬莱做网站那家好Problem - B - Codeforces
问题描述#xff1a;excel有两种情况#xff0c;
Rr_nCc_n#xff1a;R行数C列数ZZZ(列数)行数。
对这两个进行相互转换。
细节#xff1a;
准确判断这两种情况
string str; cinstr;
auto posR str.find(R), posC st…Problem - B - Codeforces
问题描述excel有两种情况
Rr_nCc_nR行数C列数ZZZ(列数)行数。
对这两个进行相互转换。
细节
准确判断这两种情况
string str; cinstr;
auto posR str.find(R), posC str.find(C);
bool fg false;
if(isdigit(str[posR1])) fg true;
if(fg posR ! -1 posC ! -1 posR posC) {// 第一种情况
} else {// 第二种情况
}十进制到26进制带字母注意 ‘A’‘Z’。
col ( (cv % 26 0 ? 25 : cv % 26 - 1) A);
if(cv % 26 0) cv--;
cv / 26;AC代码
#include iostream
#include vector
#include string
#include cstring
#include set
#include map
#include queue
#include ctime
#include random
#include sstream
#include numeric
#include stdio.h
#include functional
#include bitset
#include algorithm
using namespace std;// #define Multiple_groups_of_examples
#define IOS std::cout.tie(0);std::cin.tie(0)-sync_with_stdio(false);
#define dbgnb(a) std::cout #a a \n;
#define dbgtt cout !!!test!!! endl;
#define rep(i,x,n) for(int i x; i n; i)#define all(x) (x).begin(),(x).end()
#define pb push_back
#define vf first
#define vs secondtypedef long long LL;
typedef pairint,int PII;const int INF 0x3f3f3f3f;
const int N 2e5 21;void inpfile();
void solve() {int n; cinn;while(n--) {string str; cinstr;auto posR str.find(R), posC str.find(C);bool fg false;if(isdigit(str[posR1])) fg true;if(fg posR ! -1 posC ! -1 posR posC) {// R ... C ...int rv 0, cv 0;posR;while(isdigit(str[posR])) {rv rv * 10 str[posR] - 0;posR;}posR;while(isdigit(str[posR])) {cv cv * 10 str[posR] - 0;posR;}string col ;while(cv) {col ( (cv % 26 0 ? 25 : cv % 26 - 1) A);if(cv % 26 0) cv--;cv / 26;}reverse(all(col));coutcol; coutrvendl;} else {int pos 0;while(isalpha(str[pos])) {pos;}int rv 0;string s ;for(int i 0; i pos; i) {s str[i];}int cv 0;for(int i 0; i pos; i) {cv cv * 26 (s[i] - A 1);}while(isdigit(str[pos])) {rv rv * 10 str[pos] - 0;pos;}coutRrvCcvendl;}}
}
int main()
{#ifdef Multiple_groups_of_examplesint T; cinT;while(T--)#endifsolve();return 0;
}
void inpfile() {#define mytest#ifdef mytestfreopen(ANSWER.txt, w,stdout);#endif
}