TopCoder 250 points 8-SRM 147 DIV 2 176.36/250 70.54%
来源:互联网 发布:java免费开源商城系统 编辑:程序博客网 时间:2024/05/17 07:34
Problem Statement
Julius Caesar used a system of cryptography, now known as Caesar Cipher, which shifted each letter 2 places further through the alphabet (e.g. 'A' shifts to 'C', 'R' shifts to 'T', etc.). At the end of the alphabet we wrap around, that is 'Y' shifts to 'A'.
We can, of course, try shifting by any number. Given an encoded text and a number of places to shift, decode it.
For example, "TOPCODER" shifted by 2 places will be encoded as "VQREQFGT". In other words, if given (quotes for clarity) "VQREQFGT" and 2 as input, you will return "TOPCODER". See example 0 below.
Definition
Class:CCipherMethod:decodeParameters:String, intReturns:StringMethod signature:String decode(String cipherText, int shift)(be sure your method is public)Constraints
-cipherText has between 0 to 50 characters inclusive-each character of cipherText is an uppercase letter 'A'-'Z'-shift is between 0 and 25 inclusiveExamples
0)"VQREQFGT"
2
Returns: "TOPCODER"1)
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
10
Returns: "QRSTUVWXYZABCDEFGHIJKLMNOP"2)
"TOPCODER"
0
Returns: "TOPCODER"3)
"ZWBGLZ"
25
Returns: "AXCHMA"4)
"DBNPCBQ"
1
Returns: "CAMOBAP"5)
"LIPPSASVPH"
4
Returns: "HELLOWORLD"
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.
这道也非常简单,DIV 2里面简单的练手题
public class CCipher {public String decode(String cipherText, int shift) {int len = cipherText.length();if (len == 0)return "";StringBuilder sb = new StringBuilder();char array[] = cipherText.toCharArray();for (int i = 0; i < len; i++) {int a = array[i] - shift;int b = a + 26;array[i] = array[i] - 'A' >= shift ? (char) a : (char) b;sb.append(array[i]);}return sb.toString();}}
- TopCoder 250 points 8-SRM 147 DIV 2 176.36/250 70.54%
- TopCoder 250 points 4-SRM 145 DIV 2 128.72/250 51.49%
- TopCoder 250 points 6-SRM 146 DIV 2 162.67/250 65.07%
- TopCoder 250 points 10-SRM 148 DIV 2 167.20/250 66.88%
- TopCoder 250 points 12-SRM 149 DIV 2 103.92/250 41.57%
- TopCoder 250 points 14-SRM 150 DIV 2 86.25/250 34.50%
- TopCoder 250 points 16-SRM 151 DIV 2 97.63/250 39.05%
- TopCoder 250 points 18-SRM 152 DIV 2 167.05/250 66.82%
- TopCoder 250 points 20-SRM 153 DIV 2 216.58/250 86.63%
- TopCoder 250 points 28-SRM 157 DIV 2 185.60/250 74.24%
- TopCoder 300 points 24-SRM 155 DIV 2 75/250 30%
- 【topcoder SRM 702 DIV 2 250】TestTaking
- TopCoder算法竞赛题3:SRM 147 DIV 2, 250-point
- TopCoder 250 points 3-SRM 145 DIV 1 84.71/250 33.88%
- TopCoder 250 points 9-SRM 148 DIV 1 75/250 30%
- TopCoder 250 points 11-SRM 149 DIV 1 86.62/250 34.65%
- TopCoder 250 points 13-SRM 150 DIV 1 82.63/250 33.05%
- TopCoder 250 points 15-SRM 151 DIV 1 121.73/250 48.69%
- spring 问题
- IOS KVO
- VC++ ADO ACCESS 数据库 FLEXGRID
- 到底谁是this
- 高斯消元基础题
- TopCoder 250 points 8-SRM 147 DIV 2 176.36/250 70.54%
- MQX编写日志
- POJ 1009
- 用prototype继承整个对象
- Servlet的文件上传与下载
- Rotate Image
- Linux下搜索指定目录下文件中特定字符串并高亮显示匹配关键词
- Servlet的线程安全问题
- Binary Search Tree Analysis based on Wikipedia