【链接】 我是链接,点我呀:)

【题意】

A~Z分别对应了1~26
AA是27依次类推
让你完成双向的转换

【题解】

转换方法说实话特别恶心>_

【代码】

import java.io.*;
import java.util.*; public class Main { static InputReader in;
static PrintWriter out; public static void main(String[] args) throws IOException{
//InputStream ins = new FileInputStream("E:\\rush.txt");
InputStream ins = System.in;
in = new InputReader(ins);
out = new PrintWriter(System.out);
//code start from here
new Task().solve(in, out);
out.close();
} static int N = (int)1e6;
static class Task{ boolean isdigit(char key) {
if (key>='0' && key<='9') return true;
else return false;
} int strtoint(String s) {
int temp = 1;
int cur = 0;
int len = s.length();
for (int i = len-1;i >= 0;i--) {
cur = cur + temp*(s.charAt(i)-'A'+1);
temp = temp*26;
}
return cur;
} String inttostr(int col) {
StringBuilder sb = new StringBuilder();
int cur = 26;
int cnt = 1;
while (col>cur) {
col-=cur;
cur = cur*26;
cnt++;
}
for (int i = 1;i <= cnt;i++) {
for (int j = 26;j>=1;j--)
if ((j-1)*(cur/26)<col) {
col-=(j-1)*cur/26;
char key = (char)(j+'A'-1);
sb = sb.append(key);
cur/=26;
break;
}
}
return sb.toString();
} public void solve(InputReader in,PrintWriter out) {
int n;
n = in.nextInt();
int []num = new int[2];
for (int i = 1;i <= n;i++) {
String s = in.next();
int cnt = 0;
int len = s.length();
int fir = 0;
for (int j = 0;j < len;j++) {
if (isdigit(s.charAt(j))) {
int k = j;
fir = j;
while (k+1<len && isdigit(s.charAt(k+1)) ) k++;
//j..k全是数字
int temp = 0;
for (int l = j;l <= k;l++)
temp = temp*10+s.charAt(l)-'0';
num[cnt++] = temp;
j = k;
}
}
if (cnt==1) {
//AB12
int rows = num[0];
int col = strtoint(s.substring(0, fir));
out.println("R"+rows+"C"+col);
}else {
int rows = num[0];int cols = num[1];
String strcols = inttostr(cols);
out.println(strcols+rows);
}
}
}
} static class InputReader{
public BufferedReader br;
public StringTokenizer tokenizer; public InputReader(InputStream ins) {
br = new BufferedReader(new InputStreamReader(ins));
tokenizer = null;
} public String next(){
while (tokenizer==null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(br.readLine());
}catch(IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
} public int nextInt() {
return Integer.parseInt(next());
}
}
}

【Codeforces 1B】Spreadsheets的更多相关文章

  1. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  2. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  3. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  4. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

  5. 【codeforces 709B】Checkpoints

    [题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...

  6. 【codeforces 709C】Letters Cyclic Shift

    [题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...

  7. 【Codeforces 429D】 Tricky Function

    [题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...

  8. 【Codeforces 670C】 Cinema

    [题目链接] http://codeforces.com/contest/670/problem/C [算法] 离散化 [代码] #include<bits/stdc++.h> using ...

  9. 【codeforces 515D】Drazil and Tiles

    [题目链接]:http://codeforces.com/contest/515/problem/D [题意] 给你一个n*m的格子; 然后让你用1*2的长方形去填格子的空缺; 如果有填满的方案且方案 ...

随机推荐

  1. Tyvj 1068 巧用扩展KMP

    Tyvj1068 给定两个长度为2*10^5的字符串为A和B 求B在A中匹配后,任意匹配长度的位置个数. KMP算法大家应该烂熟于心才好,这样碰到这样的题才能灵活运用.有时做题真的需要一点灵感.首先, ...

  2. codeforces 764D

    脑洞 很早以前没有补掉的题目 四色问题肯定使有解的,然后就是怎么构造.注意到边长是奇数,那么我们就可以分类,按左上角坐标的奇偶性分类,正好对应四种颜色.因为当两个矩形左上角横纵坐标奇偶性不同时,那么肯 ...

  3. openstack instance bootmgr is missing 问题 修复

  4. redhat6 改 centos yum 源

    **redhat的yum在线更新是收费的,如果没有注册的话不能使用,如果要使用,需将redhat的yum卸载后,重启安装其他yum源,再配置其他源.** 本文包括配置本地源及第三方源.第三方源包括:网 ...

  5. 【TIDB】1、TiDb简介

    一 TiDb简介 TiDB 是 PingCAP 公司受 Google Spanner / F1 论文启发而设计的开源分布式 HTAP (Hybrid Transactional and Analyti ...

  6. CyclibcBarrier与CountDownLatch区别

    1.CyclibcBarrier的线程运行到某个位置后即停止运行,直到所有的线程都到达这个点,所有线程才开始运行:CountDownLatch是线程运行到某个点后,计数器-1,程序继续运行即Cycli ...

  7. android 虚拟机,文件导入sdcard下报错,Read-only file system

    解决方案-------------------- eclipse -> windows->Android AVD Manager 里选择你的AVD,edit里SD Card 选择File, ...

  8. ansible 显示运行时间

    #独家秘诀cd /etc/ansible mkdir callback_plugins cd callback_plugins wget https://raw.githubusercontent.c ...

  9. AP聚类

    基于代表点的聚类算法可以说是聚类算法中"最经典的,最流行的,也是最前沿的". "最经典"是因为K均值是最早出现的聚类算法之一; "最流行"是 ...

  10. html——导航demo

    通过行内块.伪类对导航栏进行设置 <!DOCTYPE html> <html> <head> <meta charset="utf-8" ...