Problem Description

we define f(A) = 1, f(a) = -1, f(B) = 2, f(b) = -2, … f(Z) = 26, f(z) = -26;

Give you a letter x and a number y , you should output the result of y+f(x).

Input

On the first line, contains a number T.then T lines follow, each line is a case.each case contains a letter and a number.

Output

for each case, you should the result of y+f(x) on a line.

Sample Input

6

R 1

P 2

G 3

r 1

p 2

g 3

Sample Output

19

18

10

-17

-14

-4

题意:we define f(A) = 1, f(a) = -1, f(B) = 2, f(b) = -2, … f(Z) = 26, f(z) = -26;Give you a letter x and a number y , you should output the result of y+f(x)..

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String lowerCase = "0abcdefghijklmnopqrstuvwxyz";
String capital = "1ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int n =sc.nextInt();
//sc.next();
while(n-->0){
String strs = sc.next();
//System.out.println(strs);
int y = sc.nextInt();
char x = strs.charAt(0);
//strs = strs.substring(2);
//int y = Integer.parseInt(strs,10); //System.out.println(x);
//System.out.println(y);
int g=0,h=0;
for(int i=1;i<lowerCase.length();i++){
if(x==lowerCase.charAt(i)){
g=-i;
break;
}
}
for(int i=1;i<capital.length();i++){
if(x==capital.charAt(i)){
h=i;
break;
}
}
System.out.println(y+g+h); } } }

HDOJ 2055 An easy problem的更多相关文章

  1. hdu 2055 An easy problem (java)

    问题: 開始尝试用字符做数组元素.可是并没实用. 在推断语句时把a z排出了. An easy problem Time Limit: 1000/1000 MS (Java/Others)    Me ...

  2. HDOJ 5475 An easy problem

    题目传送门 题意:一个计算器,两种操作,乘上x,或者除掉之前的某个x,结果取模输出 分析:因为取模不支持除法,然后比赛时想到用逆元,结果发现MOD需要与b互质,结果一直苦苦寻找求逆元的其它方法.后来队 ...

  3. HDOJ(HDU) 2132 An easy problem

    Problem Description We once did a lot of recursional problem . I think some of them is easy for you ...

  4. UVA-11991 Easy Problem from Rujia Liu?

    Problem E Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for ...

  5. An easy problem

    An easy problem Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Sub ...

  6. UVa 11991:Easy Problem from Rujia Liu?(STL练习,map+vector)

    Easy Problem from Rujia Liu? Though Rujia Liu usually sets hard problems for contests (for example, ...

  7. POJ 2826 An Easy Problem?!

    An Easy Problem?! Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7837   Accepted: 1145 ...

  8. hdu 5475 An easy problem(暴力 || 线段树区间单点更新)

    http://acm.hdu.edu.cn/showproblem.php?pid=5475 An easy problem Time Limit: 8000/5000 MS (Java/Others ...

  9. 【暑假】[实用数据结构]UVa11991 Easy Problem from Rujia Liu?

    UVa11991 Easy Problem from Rujia Liu?  思路:  构造数组data,使满足data[v][k]为第k个v的下标.因为不是每一个整数都会出现因此用到map,又因为每 ...

随机推荐

  1. sql知识点的积累和使用过的例子

    越来越发现自己的sql方面的知识的欠缺,所以只能放低姿态一点一点的学了 一 游标和charIndex的使用. 游标我一直没用过,以前只是在同事们写的存储过程里见过,但是一直没看明白(可是我就是比较笨吧 ...

  2. windows下apache+php+mysql配置

    Apache 2.4.10(文件:httpd-2.4.10-win64-VC11.zip) php 5.6.26 (文件:php-5.6.25-Win32-VC11-x64.zip) mysql 5. ...

  3. HashMap深度解析(二)

    本文来自:高爽|Coder,原文地址:http://blog.csdn.net/ghsau/article/details/16890151 上一篇比较深入的分析了HashMap在put元素时的整体过 ...

  4. angularjs-ngModel 控制页面的宽度

    js NiDialog.open({ windowClass: '', size:'elements', backdrop: 'static', keyboard: false, templateUr ...

  5. JavaScript Comparison and Logical Operators

    Ref:http://www.w3schools.com/js/js_comparisons.asp var r = 1; var result = r || 2; console.log(resul ...

  6. SQL SERVER将指定表中的指定字段按照(,)逗号分隔

    不开心呀,早知道不跳了,一跳跳坑里来了. 使用方式: DECLARE @ConsigneeAddressId INT; SET @ConsigneeAddressId = 1; SELECT  * F ...

  7. PIL安装记录,编译支持jpeg png

    PIL是python理想的图片处理module,但是想要良好的支持各种图片,还需要检查一下几步,否则会提示:IOError: decoder jpeg not available之类的. 我的环境:L ...

  8. Spring_DI利用set方法赋值Demo

    Person.java public class Person { private Long pid; private String pname; private Student student; p ...

  9. SGU 121.Bridges painting

    原题地址 题意: 新百慕大由N个岛屿组成,在岛屿之间有一些连接它们的桥.在任意两个岛屿之间,最多只有一座桥连接它们.总统先生下达命令,要求给所有桥上色. 每一座桥能被染成 白色 或者 黑色. 每一个岛 ...

  10. Bootstrap_表单_图标

    在Bootstrap框架中是通过给元素添加“glyphicon”类名来实现,然后通过伪元素“:before”的“content”属性调取对应的icon编码: <span class=" ...