问题:

開始尝试用字符做数组元素。可是并没实用。

在推断语句时把a z排出了。

An easy problem

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 16516    Accepted Submission(s): 11096

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

代码:

import java.util.*;

public class Main{
public static void M1(char str,int kk){
char aa[]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
for(int i=0;i<26;i++){
if(aa[i]==str)
System.out.println((i+1)+kk);
}
}
public static void M2(char str,int kk){
char aa[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
for(int i=0;i<26;i++){
if(aa[i]==str)
System.out.println(-(i+1)+kk);
}
}
public static void main(String[] args) {
Scanner cin=new Scanner(System.in);
int nn=cin.nextInt();
for(int ii=0;ii<nn;ii++){
String st=cin.next();
int kk=cin.nextInt();
char a[]=st.toCharArray();
char str=a[0];
if(str>='a'&&str<='z')
M2(str,kk);
else if(str>='A'&&str<='Z')
M1(str,kk); }
}
}

hdu 2055 An easy problem (java)的更多相关文章

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

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

  2. hdu 1016 Prime Ring Problem(DFS)

    Prime Ring Problem Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  3. hdu2601 An easy problem(数学)

    题目意思: http://acm.hdu.edu.cn/showproblem.php? pid=2601 给出一个数N,求N=i*j+i+j一共同拥有多少种方案. 题目分析: 此题直接暴力模拟就可以 ...

  4. HDU 2522 A simple problem (模拟)

    题目链接 Problem Description Zty很痴迷数学问题..一天,yifenfei出了个数学题想难倒他,让他回答1 / n.但Zty却回答不了^_^. 请大家编程帮助他. Input 第 ...

  5. JHDU 2601 An easy problem (数学 )

    title: An easy problem 数学 杭电2601 tags: [数学] 题目链接 Problem Description When Teddy was a child , he was ...

  6. 数学--数论-- HDU 2601 An easy problem(约束和)

    Problem Description When Teddy was a child , he was always thinking about some simple math problems ...

  7. hdu 1016 Prime Ring Problem(dfs)

    Prime Ring Problem Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  8. CF1096D Easy Problem(DP)

    貌似最近刷了好多的CF题…… 题目链接:CF原网 洛谷 题目大意:有一个长度为 $n$ 的字符串 $s$,删除第 $i$ 个字符需要代价 $a_i$.问使得 $s$ 不含有子序列(不是子串)" ...

  9. HDU 5464 ( Clarke and problem ) (dp)

    dp[i][j] := 前i个数和为j的情况(mod p) dp[i][j] 分两种情况 1.不选取第i个数 -> dp[i][j] = dp[i-1][j] 2.   选取第i个数 -> ...

随机推荐

  1. 使用SHA1、SHA2双证书进行微软数字签名

    微软是第一个宣布了SHA-1弃用计划,在2016年之后Windows和IE将不再信任SHA-1证书.正好我们公司的数字签名也到期了,索性就重新申请了sha256和sha1的新数字证书,用来给产品签名. ...

  2. Jquery学习笔记:操作form表单元素之一(文本框和下拉框)

    一.概述 在web页面开发中,经常需要获取和设置表单元素的值(如文本框中的内容),特别是在ajax应用中,更是常态.本文系统的介绍下如何操作. 同操作其它html元素一样,操作的过程差不多. 第一步, ...

  3. 高性能MySql学习笔记——锁、事务、隔离级别(转)

    为什么需要锁? 因为数据库要解决并发控制问题.在同一时刻,可能会有多个客户端对Table1.rown进行操作,比如有的在读取该行数据,其他的尝试去删除它.为了保证数据的一致性,数据库就要对这种并发操作 ...

  4. linux下执行sh文件报错:oswatcher_restart.sh: line 13: ./startOSW.sh: Permission denied

    1 查看执行sh文件的内容 [root@xxxdb0402 dbscripts]# more oswatcher_restart.sh  #!/usr/bin/ksh #export oswdir=` ...

  5. 数据绑定以及Container.DataItem几种方式与使用方法分析

    灵活的运用数据绑定操作        绑定到简单属性:<%#UserName%>        绑定到集合:<asp:ListBox id="ListBox1" ...

  6. springMVC 使用jstl

    jsp页面获取数据,感觉最方便的就是使用jstl+EL了,各种封装好的函数非常简单易用,接下来写如何使用jstl: 1.下载jstl-1.2_1.jar 2.由于项目是: xmlns="ht ...

  7. 基于visual Studio2013解决面试题之1307二分查找

     题目

  8. 基于visual Studio2013解决面试题之1101差值最小

     题目

  9. 一个必用的javascript框架:underscore.js - wine的思考 - ITeye技术网站

    AngularJS+JqueryMobile+PhoneGap 打造APP « Dogeek AngularJS+JqueryMobile+PhoneGap 打造APP

  10. Netty源代码学习——ChannelPipeline模型分析

    參考Netty API io.netty.channel.ChannelPipeline A list of ChannelHandlers which handles or intercepts i ...