时间限制: 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. springMVC拦截配置

    1.web.xml文件配置 <!-- spring mvc --> <servlet> <servlet-name>DispatcherServlet</se ...

  2. myeclipse 去掉spring特性支持

    myeclipse10.0 去掉spring支持  手工修改工程目录下的.project文件中相关的内容 删除<nature>com.genuitec.eclipse.springfram ...

  3. C# 获取汉字的拼音首字母和全拼(含源码)

    C# 获取汉字的拼音首字母 一种是把所有中文字符集合起来组成一个对照表:另一种是依照汉字在Unicode编码表中的排序来确定拼音的首字母.碰到多音字时就以常用的为准(第一种方法中可以自行更改,方法为手 ...

  4. HDU3065【AC自动机-AC感言】

    Fourth AC zi dong ji(Aho-Corasick Automation) of life 9A(其实不止交了10发...) 感言: 一开始多组数据这种小数据还是...无伤大局,因为改 ...

  5. 51nod 1449 砝码称重【天平/进制】

    题意: 给你w,n,问你在w^0,w^1,w^2...各种一个,问你能不能用这些砝码和重量为m的东西放在天平上使得天平平衡: 思路: 这个很容易联想到进制: 如果把m放在是一边的话,其实对于砝码就是纯 ...

  6. UnityEngine中Animator相关类的说明

    ---------------------------------------------------------------------- Animator 这个单独写,比较多 AnimationC ...

  7. 稳定UI运行结果-自动化测试失败重试和截图

    运行自动化测试的时候,有时会因为网络不稳定,测试环境或者第三方环境正在重启而造成用例运行结果不稳定,时而能跑过时而跑不过.这些难以重现的环境因素造成的用例失败会让测试人员很困扰,排查即耗费时间也没有太 ...

  8. C - Brackets

    #include <iostream> #include <algorithm> #include <cstring> #include <cstdio> ...

  9. java关于方法参数传递的相关问题讨论

    我们知道,java中定义变量的目的有两个: 1.防止被垃圾回收机制回收,毕竟如果没有明确指向真实物理内存的'代号'很大可能会被java垃圾回收机制当作垃圾回收. 2.便于引用,方便处理. packag ...

  10. 牛客寒假6-J.迷宫

    链接:https://ac.nowcoder.com/acm/contest/332/J 题意: 你在一个 n 行 m 列的网格迷宫中,迷宫的每一格要么为空,要么有一个障碍. 你当前在第 r 行第 c ...