【Codeforces 1B】Spreadsheets
【链接】 我是链接,点我呀:)
【题意】
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的更多相关文章
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
- 【codeforces 709D】Recover the String
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...
- 【codeforces 709B】Checkpoints
[题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...
- 【codeforces 709C】Letters Cyclic Shift
[题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...
- 【Codeforces 429D】 Tricky Function
[题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...
- 【Codeforces 670C】 Cinema
[题目链接] http://codeforces.com/contest/670/problem/C [算法] 离散化 [代码] #include<bits/stdc++.h> using ...
- 【codeforces 515D】Drazil and Tiles
[题目链接]:http://codeforces.com/contest/515/problem/D [题意] 给你一个n*m的格子; 然后让你用1*2的长方形去填格子的空缺; 如果有填满的方案且方案 ...
随机推荐
- FileZilla文件下载的目录
连接上ftp服务器之后,在remote site那边邮件选中了目录下载文件,但是下载完成之后. 不知道下载到哪里了,用search everything软件搜了一下,发现就在D盘的根目录. 所以,下载 ...
- 9.23 NOIP模拟题(数学专练)
数论基础 专题测试 命题人:清华大学 王赢绪 /* 水题 答案为C(n-k,m-1) 预处理阶乘和逆元,O(1)算答案 开始读错题了!!!朱一乐!!! */ #include<iostream ...
- [App Store Connect帮助]一、 App Store Connect 使用入门(1)App Store Connect 工作流程
您使用 App Store Connect 提交并管理您在 App Store 中销售的 App,使用 TestFlight 分发您 App 的 Beta 版本,接受法律协议,输入您的税务和银行业务信 ...
- [Swift通天遁地]五、高级扩展-(13)图片资源本地化设置:根据不同的语言环境显示不同语言版本图片
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- python3+request接口自动化框架
首次书写博客,记录下写的自动化接口框架,框架比较简单,哈哈哈,算是记录下历程把!~~~ 一.本次框架由python3.6 书写 1.准备代码环境,下载python3.6 下载地址:https:/ ...
- 解决macOS升级之后每次使用ssh都要输入密码的问题
最近想趁着假期把跟了我2年mac的系统重做下.于是就开始行动了,经过大半天的数据备份.然后进行了全盘格式化,使用了在线更新的方式从新安装升级到了10.12.6.这里提醒下有类似的想法的同学可以采用 ...
- BZOJ 3473
思路: CF原题 ZYF有题解 O(nlog^2n) //By SiriusRen #include <bits/stdc++.h> using namespace std; ; ]; i ...
- JavaWeb项目中引入spring框架
主要步骤有以下3步: 1:下载spring的jar包2:在项目中web.xml中添加spring配置3:bean配置文件-applicationContext.xml 1:引入包,这个就不说了,官网下 ...
- java攻城狮之路--复习JDBC(数据库连接池 : C3P0、DBCP)
复习数据库连接池 : C3P0.DBCP 1.数据库连接池技术的优点: •资源重用: 由于数据库连接得以重用,避免了频繁创建,释放连接引起的大量性能开销.在减少系统消耗的基础上,另一方面也增 ...
- 注释及Scriptlet
1.显式注释 <!--xxxxxx-->,在正常页面上也看不出来,右键鼠标查看源代码可以看到 2.隐式注释 //xxxxx /*xxxxxx*/ <%--xxxxxxx--> ...