时间限制: 1 s
 空间限制: 128000 KB
 题目等级 : 白银 Silver
题目描述 Description

Sheldon and Leonard are physicists who are fixated on the BIG BANG theory. In order to exchange secret insights they have devised a code that encodes UPPERCASE words by shifting their letters forward.

谢耳朵和莱纳德是研究BB理论的物理学家。要用暗号(大写字母)联系。

Shifting a letter by S positions means to go forward S letters in the alphabet. For example, shifting B by S = 3 positions gives E. However, sometimes this makes us go past Z, the last letter of the alphabet. Whenever this happens we wrap around, treating A as the letter that follows Z. For example, shifting Z by S = 2 positions gives B.

(读懂这段话是解题的关键,翻译了就没意义了)

Sheldon and Leonard’s code depends on a parameter K and also varies depending on the position of each letter in the word. For the letter at position P, they use the shift value of S = 3P + K.

他们有一个密钥K。第P个字母有S = 3P + K。

For example, here is how ZOOM is encoded when K = 3. The first letter Z has a shift value of S = 3 × 1 + 3 = 6; it wraps around and becomes the letter F. The second letter, O, has S = 3 × 2 + 3 = 9 and becomes X. The last two letters become A and B. So Sheldon sends Leonard the secret message: FXAB
Write a program for Leonard that will decode messages sent by Sheldon.

输入描述 Input Description

The input will be two lines. The first line will contain the positive integer K (K < 10), which is used to compute the shift value. The second line of input will be the word, which will be a sequence of uppercase characters of length at most 20.

输入有两行。第一行一个正整数K(〈10)。第二行是最多20个大写字母组成的信。

输出描述 Output Description

The output will be the decoded word of uppercase letters.

输入就是解密后的信。

样例输入 Sample Input

样例1:

3

FXAB

样例2:

5

JTUSUKG

样例输出 Sample Output

样例1:

ZOOM

样例2:

BIGBANG

数据范围及提示 Data Size & Hint
 
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath> using namespace std; int main()
{
char b[];
int i,k,s;
scanf("%d",&k);
scanf("%s",b);
for(i=;b[i];i++)
{
s=*(i+)+k;
if(b[i]-s<'A')
{
s-=b[i]-'A';
b[i]='Z'+;
}
printf("%c",b[i]-s);
}
}

codevs 1277 生活大爆炸 2012年CCC加拿大高中生信息学奥赛的更多相关文章

  1. code vs1262 不要把球传我(组合数学) 2012年CCC加拿大高中生信息学奥赛

    1262 不要把球传我 2012年CCC加拿大高中生信息学奥赛  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 白银 Silver 题解  查看运行结果     题目描述 De ...

  2. 1269 匈牙利游戏 2012年CCC加拿大高中生信息学奥赛

    1269 匈牙利游戏 2012年CCC加拿大高中生信息学奥赛 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond         题目描述 Description ...

  3. 1267 老鼠的旅行 2012年CCC加拿大高中生信息学奥赛

    1267 老鼠的旅行  2012年CCC加拿大高中生信息学奥赛 题目描述 Description You are a mouse that lives in a cage in a large lab ...

  4. codevs 1262 不要把球传我 2012年CCC加拿大高中生信息学奥赛

    时间限制: 1 s  空间限制: 128000 KB  题目等级 : 白银 Silver 题目描述 Description CCC的足球比赛和传统的足球比赛有一点不同, 一次进球当且仅当先后接触到球的 ...

  5. CODEVS——T 1269 匈牙利游戏 2012年CCC加拿大高中生信息学奥赛

    http://codevs.cn/problem/1269/  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond 题解       题目描述 Descript ...

  6. 【动态规划】【记忆化搜索】【搜索】CODEVS 1262 不要把球传我 2012年CCC加拿大高中生信息学奥赛

    可以暴力递归求解,应该不会TLE,但是我们考虑记忆化优化. 设f(i,j)表示第i个数为j时的方案数. f(i,j)=f(1,j-1)+f(2,j-1)+……+f(i-1,j-1) (4>=j& ...

  7. codevs 1267 老鼠的旅行 2012年CCC加拿大高中生信息学奥赛

    时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题目描述 Description You are a mouse that lives in a cage in ...

  8. Codevs 1200 同余方程 2012年NOIP全国联赛提高组

    1200 同余方程 2012年NOIP全国联赛提高组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题目描述 Description 求关于 x 同余方程 a ...

  9. codevs 1200 同余方程 2012年NOIP全国联赛提高组 x

    /*我在提交的时候发现了一个特别好玩的事,有兴趣的话,可以自己尝试一下:把下面说的地方的y=0改为y=1在codevs里面能够ac,这……数据水?到一定境界……厉害了,吓得我还以为自己对了,结果一讲才 ...

随机推荐

  1. 2.11 Hive中数据导入导出Import和Export使用

    https://cwiki.apache.org/confluence/display/Hive/LanguageManual+ImportExport 一.Export.Import Export ...

  2. 继承映射关系 subclass的查询

    Person大类的映射文件配置 1 <hibernate-mapping package="com.zh.hibernate.subclass"> <class ...

  3. 接口开发之PHP创建XML文件

    用PHP的DOM控件来创建输出 输出的格式为XML 接口开发的相关文件及说明 <?php header("Content-type: text/xml");//头文件非常重要 ...

  4. Linux 一些问题

    终端以root账号执行 su - root

  5. MyBatist庖丁解牛(四)

    什么是MyBatis-Spring? MyBatis-Spring就是帮助你将MyBatis代码无缝的整合到Spring中.Spring将会加载必要的sqlSessionFactory类和sessio ...

  6. js实现打印正三角

    代码: <html> <head> <title>function</title> </head> <body> <scr ...

  7. 未知宽高div水平垂直居中的3种方法

    方法一 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8 ...

  8. css-原理详解

    语法 CSS 规则由两个主要的部分构成:选择器,以及一条或多条声明: 选择器一般使用id或者class选择器,声明由{}包含,每条声明由一个属性和一个值组成. .city { float:left; ...

  9. jave之set和get的用法

    package com.xxl.api.admin; public class Test { private int score; public int getScore() { return sco ...

  10. Technocup 2017 - Elimination Round 1 (Unofficially Open for Everyone, Rated for Div. 2) D

    The organizers of a programming contest have decided to present t-shirts to participants. There are ...