xmu 1012

来源:互联网 发布:淘宝手机怎么换购 编辑:程序博客网 时间:2024/05/18 03:23
Description

    很多人的电脑里面都有一些隐私,TheBeet也不例外。为了保护这些东西不被别人发现,TheBeet写了一个加密程序加密。不过今天,很不幸的,你得到了TheBeet电脑里面加密后的东西和他加密程序的源代码。现在,好奇的你想知道TheBeet的秘密。

下面是加密程序的源代码:

#include <cstdio>#include <cctype>int main(){        char inp;        int i = 0;        while (scanf("%c", &inp) != EOF)        {                if ((inp >= 'A') && (inp <= 'Z'))                {                        inp = ((inp - 'A') + i) % 26 + 'A';                }                else if ((inp >= 'a') && (inp <= 'z'))                {                        inp = ((inp - 'a') + i) % 26 + 'a';                }                ++i;                printf("%c", inp);        }        return 0;}

 

Input

输入一段文字,表示加密后的内容。

Output

输出加密前的内容,注意请不要遗漏任何字符和输出多余的字符。

 

Sample Input

Fmghxntn csxq rduj gio yjtr ob rktwai as nel. Wvj gs sgdpqe jn 4 lsphj lciyb H gkuwy zif jah? Y kmcgh pdmfoeiw, drftpym, ff nca zdavvljzr Hqkysmvdk Utgkqp, 4 ahewy ipy, sfdc lay ilkdnu L xgd hyf faxbv, un vmt xgui chttsys cjj gy odb blbuvvtut jxo gigdvv sjqo gebf ffir, gtfu ixv liap qtntgw lrve csuawcw gg tkrp rpub hnlmt, U ycun, C gkcv ujdx O ejc myftquq xmqki oo bsz. Bqoy, oujvj mzrbpzl orrynz' ymerfkqkahh wkb psalrl, gxec tfpsv thy vmtr ylwiut, izge pjkamoya rn mkii gul izge pigakuoell fpt jzzbzn hqes qcd monllflz lquxlaboo bb cp fyhkow. Zqx bkym dsq uaqdgkipo ymd uxrse orbw jvdc A ugsxwr ether vn dz fvphv mbz ocrt qi re trpp jwix. Tfvo, zcuwdpqe gxe irft wsk wavmmd ob boslnce qftqdk uiz G hbf rt plnk mocjj zhq pl arjfji zoic rgyt rvlpyzj wnu cqh sl. Cz V hsywfyy kmshjpj gaa cy inwi, lh rwfr fpt es hxybzbewpjv hjkkortnjvb. Zptu yaj -- lay wophvbn sk nzjnfmgwdd, B maxjhzf L fs adms nb yuahn peys pph xnvcun oespjv mbz lnoosvxrnzf jxo fsxpv bn ekqsebf sk qcbd inwiyey.

 

Sample Output

Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I still remember, vividly, on the beautiful Zhangzhou Campus, 4 years ago, from the moment I saw you smile, as you were walking out of the classroom and turned your head back, with the soft sunset glow shining on your rosy cheek, I knew, I knew that I was already drunk on you. Then, after several months' observation and prying, your grace and your wisdom, your attitude to life and your aspiration for future were all strongly impressed on my memory. You were the glamorous and sunny girl whom I always dream of to share the rest of my life with. Alas, actually you were far beyond my wildest dreams and I had no idea about how to bridge that gulf between you and me. So I schemed nothing but to wait, to wait for an appropriate opportunity. Till now -- the arrival of graduation, I realize I am such an idiot that one should create the opportunity and seize it instead of just waiting.

Hint

Sample output is a part of POJ2482's Description, slight changes.

Source
xmu
 
按照题目的要求翻译就行了,就是一个取余数的过程注意负数的取余计算过程
一个负数对于一个正数的取余数结果也必然是一个小于等于零的整数,
例如   a%b=r 其中a<0 b>0 则计算结果 r 的范围为 (-b,0]。
但是我们需要的是非负整数,则只需在进行一次计算: (r+b)%b 为对应的非负整数;
剩下的就是照着翻译就行了代码如下
 
#include<stdio.h>int main(){       char inp;        int i = 0;        while (scanf("%c", &inp) != EOF)        {                if ((inp >= 'A') && (inp <= 'Z'))                        inp =(((inp-'A')-i)%26+26)%26 + 'A';                else if ((inp >= 'a') && (inp <= 'z'))                        inp = (((inp-'a')-i)%26+26)%26+ 'a';                printf("%c", inp);i++;        }        return 0;}

0 0
原创粉丝点击