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

【题意】

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. poj2262 Goldbach's Conjecture——筛素数

    题目:http://poj.org/problem?id=2262 水水更健康~ 代码如下: #include<iostream> #include<cstdio> #incl ...

  2. JSP-Runoob:JSP 日期处理

    ylbtech-JSP-Runoob:JSP 日期处理 1.返回顶部 1. JSP 日期处理 使用JSP最重要的优势之一,就是可以使用所有Java  API.本章将会详细地讲述Java中的Date类, ...

  3. openstack instance resize to

    Icehouse resize No valid host was found Hi all!! We're currently experimenting an error that's it's ...

  4. codevs1369 xth 砍树(线段树)

    1369 xth 砍树  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond     题目描述 Description 在一个凉爽的夏夜,xth 和 rabbi ...

  5. Unity项目 - 吃豆人Pacman

    项目展示 Github项目地址:Pacman 涉及知识 切片制作 Animations 状态机设置,any state切换,重写状态机 按键读取进行整数距离的刚体移动 用射线检测碰撞性 渲染顺序问题 ...

  6. C# 单例3种写法

    public class Singleton { private static Singleton _instance = null; private Singleton(){} public sta ...

  7. $P5018 对称二叉树$

    problem 一直忘记给这个题写题解了. 这题挺水的吧. 挺后悔当时没写出来. #ifdef Dubug #endif #include <bits/stdc++.h> using na ...

  8. ACM_小G的循环

    小G的循环 Time Limit: 2000/1000ms (Java/Others) Problem Description: 一回生,二回熟,三回就腻,小G用for,while循环用得太多了,累觉 ...

  9. java中String类为什么要设计成final?

    1 将方法或类声明为final主要目的是:确保它们不会在子类中改变语义.String类是final类,这意味着不允许任何人定义String的子类. String基本约定中最重要的一条是immutabl ...

  10. CNN结构:Windows使用FasterRCNN-C++版本

    参考文章:Windows下VS2013 C++编译测试faster-rcnn. 本文与作者的所写方法有些许不同,欲速则不达,没有按照作者的推荐方法,绕了个弯弯. Windows版本纯C++版本的Fas ...