时间限制: 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. ETL 循环导入 平面文件

    http://blog.csdn.net/zlp321002/article/details/3413365 ETL设计之-Foreach 循环容器 应用场景: 批量导入某一文件夹下的所有文件.就可以 ...

  2. Git(一)

    Git概念 Git其实是一种分布式版本控制系统,与CVS,Subversion等集中化的版本控制系统相对.它主要有几个特点: • 速度快 • 简单的设计 • 对非线性开发模式的强力支持(允许上千个并行 ...

  3. Flutter实战视频-移动电商-35.列表页_上拉加载更多制作

    35.列表页_上拉加载更多制作 右侧列表上拉加载配合类别的切换 上拉加载需要一个page参数,当点击大类或者小类的时候,这个page就要变成1 provide内定义参数 首先我们需要定义一个page的 ...

  4. Flutter实战视频-移动电商-36.FlutterToast插件使用

    36.FlutterToast插件使用 https://github.com/PonnamKarthik/FlutterToast fluttertoast: ^ category_page.dart ...

  5. CodeForces 496D Tennis Game (暴力枚举)

    题意:进行若干场比赛,每次比赛两人对决,赢的人得到1分,输的人不得分,先得到t分的人获胜,开始下场比赛,某个人率先赢下s场比赛时, 游戏结束.现在给出n次对决的记录,问可能的s和t有多少种,并按s递增 ...

  6. UVa 12661 Funny Car Racing (dijkstra)

    题意:给定一个有向图,每条路有5个整数修饰,u, v, a, b, t,表示起点为u,终点为v,打开时间a,关闭时间为b,通过时间为t,打开关闭是交替进行的, 问你从s到t最短时间是多少. 析:使用d ...

  7. Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

    一.前言 Job for mysqld.service failed because the control process exited with error code. See "sys ...

  8. 查看python 3中的内置函数列表,以及函数功能描述

    >>> dir(__builtins__)//查看内置函数(BIF)列表 ['ArithmeticError', 'AssertionError', 'AttributeError' ...

  9. Jmeter + Junit

    在使用jmeter中Junit的功能之前,最好将接口以手动的方式调通,可以参考 Jmeter之HTTP Request 下面开始讲一下如何使用Junit功能 1.  编写测试类 JmeterJunit ...

  10. [WIP]webpack 概念

    创建: 2019/04/09 概念    入口 指示 webpack 应该使用哪个模块,来作为构建其内部依赖图的开始. 进入入口起点后,webpack 会找出有哪些模块和库是入口起点(直接和间接)依赖 ...