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. 关于NetworkInfo对象的isConnected()与isAvailable()

      public class MainActivity extends Activity{    /** Called when the activity is first created. */   ...

  2. ASP.NET Web API 文件產生器 - 使用 Swagger

    转帖:http://kevintsengtw.blogspot.hk/2015/12/aspnet-web-api-swagger.html Swagger 是一套 API 互動文件產生器,使用 HT ...

  3. NgNice项目案例

    技术构架: 服务端技术:NodeJS + Express4.x + Mongodb + Mongoose 前端技术: AngularJS1.2.x + Bootstrap3.x 源码:https:// ...

  4. kvc简单实现

      除了一般的赋值和取值的方法,我们还可以用Key-Value-Coding(KVC)键值编码来访问你要存取的类的属性 kvc: kvc    key value coding 键值对编码 可以通过 ...

  5. WPF里面的常用笔刷

    程序运行效果 <Window x:Class="This_brush.MainWindow" xmlns="http://schemas.microsoft.com ...

  6. spring-quartz普通任务与可传参任务

    两者区别与作用: 普通任务:总调度(SchedulerFactoryBean)--> 定时调度器(CronTriggerFactoryBean) --> 调度明细自定义执行方法bean(M ...

  7. 用Python高亮org-mode代码块

    文章同时可在我的github blog上阅读:http://cheukyin.github.io/python/2014-08/pygments-highlight-src-export-html.h ...

  8. Eclipse 编译StanfordNLP

    1.源码最新下载地址:http://nlp.stanford.edu/software/index.shtml; 2.解压stanford-corenlp.zip; 3.打开Eclipse新建JAVA ...

  9. python str + int

    TypeError: cannot concatenate 'str' and 'int' objects 1. print 'Is your secret number " + str(p ...

  10. Android中AppWidget的分析与应用:AppWidgetProvider .

    from: http://blog.csdn.net/thl789/article/details/7887968 本文从开发AppWidgetProvider角度出发,看一个AppWidgetPrv ...