a letter and a number
描述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).
- 输入
- On the first line, contains a number T(0<T<=10000).then T lines follow, each line is a case.each case contains a letter x and a number y(0<=y<1000).
- 输出
- for each case, you should the result of y+f(x) on a line
- 样例输入
-
- 6
- R 1
- P 2
- G 3
- r 1
- p 2
- g 3
- 6
- 样例输出
-
- 19
- 18
- 10
- -17
- -14
- -4
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner=new Scanner(System.in);
- int T;
- char s[]=new char[1];
- int result;
- int number;
- T=scanner.nextInt();
- while(true){
- if(T==0)
- break;
- T--;
- s=scanner.next().toCharArray();
- number=scanner.nextInt();
- if(s[0]>='a' && s[0]<='z'){
- result=-(s[0]-'a'+1)+number;
- }
- else
- result=(s[0]-'A'+1)+number;
- System.out.println(result);
- }
- }
- }
- 19
a letter and a number的更多相关文章
- nyoj 217-a letter and a number (char)
217-a letter and a number 内存限制:64MB 时间限制:3000ms 特判: No 通过数:4 提交数:5 难度:1 题目描述: we define f(A) = 1, f( ...
- Topcoder SRM 627 div1 HappyLettersDiv1 : 字符串
Problem Statement The Happy Letter game is played as follows: At the beginning, several players ...
- shell流程控制&函数
条件 if-then-elif-then-fi if的条件部分经常使用test EXPRESSION或[ EXPRESSION ]实现,test的用法可以参见test if 条件1 #if 条件1;t ...
- Differences between volume, partition and drive
A drive is a physical block disk. For example: /dev/sda. A partition A drive can be divided into som ...
- Typographical Concepts
Glyph(字形) A glyph is an element of writing: an individual mark on a written medium that contributes ...
- 转载:fstream和ifstream详细用法
文件 I/O 在C++中比烤蛋糕简单多了.在这篇文章里,我会详细解释ASCII和二进制文件的输入输出的每个细节,值得注意的是,所有这些都是用C++完成的. 一.ASCII 输出 为了使用下面的方法, ...
- C++文件读写总结
在C++中如何实现文件的读写? 作者: infobillows 发表日期: 2007-04-03 21:33 点击数: 465 一.ASCII 输出 为了使用下面的方法, 你必须包含头文件<fs ...
- HDOJ 2055 An easy problem
Problem Description we define f(A) = 1, f(a) = -1, f(B) = 2, f(b) = -2, - f(Z) = 26, f(z) = -26; Giv ...
- HDU_2055——刷题不要使用fflush()
Problem Description we define f(A) = 1, f(a) = -1, f(B) = 2, f(b) = -2, ... f(Z) = 26, f(z) = -26; G ...
随机推荐
- Azure linux centos 默认登陆账号是什么?
什么?刚创建的linux虚拟机账号忘记了? 不要急,往下看!! Azure为我们考虑好了,默认创建centos 系统时,默认账号是azureuser,这个账号是非root权限的. 很多人在创建的时候容 ...
- HDOJ_1010 Tempter of the Bone
http://acm.hdu.edu.cn/showproblem.php?pid=1010 奇偶剪枝:可以把map看成这样: 0 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 0 1 ...
- 完成端口iocp——在螺丝壳里做道场
WINDOWS 2000以后的操作系统才支持IOCP.WINSOCK2.0才支持IOCP. 首先要有一个WINSOCK2.PAS的WINSOCK2.0接口调用声明单元. WINSOCK的版本号: WI ...
- MVC6与Asp.net5
http://www.cnblogs.com/n-pei/p/4263148.html https://blogs.msdn.microsoft.com/scottgu/2015/04/30/asp- ...
- ags js下载地址
https://developers.arcgis.com/en/downloads/ 备用
- TCP客户机-服务器
1 僵尸进程 2 信号处理 信号: 1 由一进程发往另一进程 2 由内核发往某进程 僵尸状态: 父进程取回子进程的相关信息,进程的ID,终止状态,子进程的资源利用信息 编程时: 1 当派生子进 ...
- 12.组合(Composition)
组合也是关联关系的一种特例,它体现的是一种contains-a的关系,这种关系比聚合更强,也称为强聚合:它同样体现整体与部分间的关系,但此时整体与部分是不可分的,它们具有统一的生存期,整体的生命周期结 ...
- 如何判断js中的数据类型(转)
如何判断js中的数据类型:typeof.instanceof. constructor. prototype方法比较 如何判断js中的类型呢,先举几个例子: var a = "iamstri ...
- IAR EWARM Argument variables $PROJ_DIR$ $TOOLKIT_DIR$
在IAR中的help中输入argument variables时会找到这样的一个列表: Argument variables On many of the pages in the Options d ...
- Pre-compile (pre-JIT) your assembly on the fly, or trigger JIT compilation ahead-of-time (转)
Introduction All .NET developers know that one of the best features of the CLR is JIT-compilation: J ...