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. "_Default"同时存在于两个dll文件中的解决办法

    编译器错误消息:CS0433: 类型“_Default”同时存在于“c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Fi ...

  2. ActionResult 常见问题

    1:在Asp.net Mvc 2中由于对数据的保护,当返回类型为JsonResult时 ,默认情况下request需要为post.(可使用   return Json(person,JsonReque ...

  3. C#超时处理(转载)

    /// <summary>    /// 超时处理    ///    ///    /// </summary>    public class TimeoutChecker ...

  4. c# 连接oracle 读取数据

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  5. mysql数据库中编码问题(续)

    其实之前的数据库中文乱码问题并没有彻底的解决,虽然在网页上显示正常,但是在数据库中却是乱码,虽然用户看起来没问题,但是自己就遭罪了,而且也是个极大的问题 究其原因,是没注意到一点,就是数据库中表的结构 ...

  6. java 对于url地址的实体符号的处理

    <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 <dependency> <g ...

  7. SGU 137.Funny String

    题目描述 一个序列S1 S2 S3... Sn 如果满足 新序列 S1-1 S2 S3 ...Sn+1能够通过旋转的操作(不是翻转)来得到旧的序列,那么这个序列就叫做Funny序列.例如 1 2 1 ...

  8. 【POJ3481】【splay】Double Queue

    Description The new founded Balkan Investment Group Bank (BIG-Bank) opened a new office in Bucharest ...

  9. python中xrange和range的区别

    这两个基本上都是在循环的时候用. for i in range(0, 100): print i for i in xrange(0, 100): print i 这两个输出的结果都是一样的,实际上有 ...

  10. sencha touch中用来格式化日期的字符串参数