1B. Spreadsheets(字符串+数学)
来源:互联网 发布:淘宝卖家开通花呗设置 编辑:程序博客网 时间:2024/04/29 19:34
脑残题。。。。(两种模式字符串互相转换)
还送了几发WA,原因是判断当前字符串是第一种模式还是第二种模式时出错了
代码如下:
/* ***********************************************Author :yinhuaCreated Time :2014年12月12日 星期五 14时06分37秒File Name :1B.cpp************************************************ */#include <cmath>#include <cstdio>#include <string>#include <cstring>#include <iostream>#include <algorithm>#define MAXN 10010#define LL long longusing namespace std;int tmp[MAXN];char str[10000];int main() { char ch1, ch2; int T, i, row, col; scanf("%d", &T); while(T--) { memset(str, 0, sizeof(str)); scanf("%s", str); int len = strlen(str); bool ok = false; for(i=0; i<len; ++i) { if(str[i]>='0'&&str[i]<='9') { ok = true; continue; } if(ok && str[i]>='A'&&str[i]<='Z') break; } //printf("i = %d\n", i); if(str[0] == 'R' && i!=len) { sscanf(str, "%c%d%c%d", &ch1, &row, &ch2, &col); //printf("ch1 = %c\tch2 = %c\n", ch1, ch2); //printf("%d %d\n", row, col); int cnt = 0; while(col) { if(col%26 == 0) { tmp[cnt++] = 26; col = col/26-1; } else { tmp[cnt++] = col%26; col = col/26; } } for(int i=cnt-1; i>=0; --i) { printf("%c", 'A'+tmp[i]-1); } printf("%d\n", row); } else { row = col = 0; for(int i=0; i<len; ++i) { if(str[i]>='A' && str[i]<='Z') { col = col*26+(str[i]-'A'+1); } if(str[i]>='0' && str[i]<='9') { row = row*10+(str[i]-'0'); } } printf("R%dC%d\n", row, col); } } return 0;}
0 0
- 1B. Spreadsheets(字符串+数学)
- codeforces-1B-Spreadsheets( C++ && PHP && 字符串操作 && 数学逻辑 )
- CodeForces 1B. Spreadsheets(模拟)
- CodeForces 1B Spreadsheets(EXCEL)
- CodeForces 1B Spreadsheets(模拟)
- CODEFORCES:1B. Spreadsheets
- cf 1B. Spreadsheets
- Round #1 B. Spreadsheets
- CodeForces 1B Spreadsheets
- CodeForces - 1B Spreadsheets
- Codeforces 1B. Spreadsheets
- codeforces-1B. Spreadsheets
- cf # 1 B. Spreadsheets
- 1B. Spreadsheets
- CodeForces 1B Spreadsheets
- CodeForces#1B Spreadsheets
- 1B. Spreadsheets
- Codeforces #1 B. Spreadsheets
- Eclipse+hibernate+mysql错误:Reading schema error解决
- 缓存策略优化
- QOpenGLWindow 、QOpenGLWidget 和 QPainter混合渲染方法初探
- NYOJ349 Sorting It All Out(拓扑排序)
- UnicodeEncodeError: 'latin-1' codec can't encode characters in position 4-5: ordinal not in range(25
- 1B. Spreadsheets(字符串+数学)
- 对第四维,时间的感知
- [python]Python操作MySQL
- 使用ContentProvider读取短信,备份短信
- ACM第K大数——双二分
- Dos中的地址重定位
- HDU Today(杭电oj2112)(迪杰斯特拉+map)
- easyui 的 DataGrid View 使用
- soft lockup detected