凉脾的比赛

Posted wsytj

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了凉脾的比赛相关的知识,希望对你有一定的参考价值。

A - DRM Messages

DRM Encryption is a new kind of encryption. Given an encrypted string (which we’ll call a DRM message), the decryption process involves three steps: Divide, Rotate and Merge. This process is described in the following example with the DRM message “EWPGAJRB”:

Divide

– First, divide the message in half to “EWPG” and “AJRB”.

Rotate

– For each half, calculate its rotation value by summing up the values of each character (A=0,B=1,,Z=25A=0,B=1,…,Z=25). The rotation value of “EWPG” is 4+22+15+6=474+22+15+6=47. Rotate each character in “EWPG” 4747 positions forward (wrapping from Z to A when necessary) to obtain the new string “ZRKB”. Following the same process on “AJRB” results in “BKSC”.

Merge

– The last step is to combine these new strings (“ZRKB” and “BKSC”) by rotating each character in the first string by the value of the corresponding character in the second string. For the first position, rotating ‘Z’ by ‘B’ means moving it forward 1 character, which wraps it around to ‘A’. Continuing this process for every character results in the final decrypted message, “ABCD”.

Input

The input contains a single DRM message to be decrypted. All characters in the string are uppercase letters and the string’s length is even and 15000≤15000.

Output

Display the decrypted DRM message.

Sample Input 1Sample Output 1
EWPGAJRB
ABCD
Sample Input 2Sample Output 2
UEQBJPJCBUDGBNKCAHXCVERXUCVK
ACMECNACONTEST

 

思路:
  模拟,比赛的时候找了半天的bug,没想到是把i写成l了!!!

 1 #include <iostream>
 2 #include <algorithm>
 3 #include <cstdio>
 4 #include <string>
 5 using namespace std;
 6 int main()
 7 {
 8     string s;
 9     int a[15005];
10     int s1=0,s2=0;
11     cin>>s;
12     int l=s.size();
13     for(int i=0;i<l;i++)
14     {
15         a[i]=s[i]-A;    
16     }
17     for(int i=0;i<l/2;i++)
18     {
19         s1+=a[i];
20     }
21     for(int i=l/2;i<l;i++)
22     {
23         s2+=a[i];
24     }
25     s1%=26;
26     s2%=26;
27     for(int i=0;i<l/2;i++)
28     {
29         a[i]+=s1;
30         a[i]%=26;
31     }
32     for(int i=l/2;i<l;i++)
33     {
34         a[i]+=s2;
35         a[i]%=26;
36     }
37     for(int i=0;i<l/2;i++)
38     {
39         a[i]+=a[i+l/2];
40         a[i]%=26;
41         cout<<char(a[i]+A);
42     }
43     
44     
45 
46     
47 }

以上是关于凉脾的比赛的主要内容,如果未能解决你的问题,请参考以下文章

两个乒乓球队进行比赛,各出三人。甲队为a,b,c三人,乙队为x,y,z三人。 已抽签决定比赛名单。有人向队员打听比赛的名单。 a说他不和x比,c说他不和x,z比,请编程序找出三队赛手的名单。(代码片段

十大视频场景化应用工具+五大视频领域冠军/顶会算法开源

Firebase实时数据库GroupBy方法

十大视频场景化应用工具+五大视频领域冠军顶会算法重磅开源!

解密体育背后AI黑科技:花样滑冰动作识别多模视频分类和精彩片段剪辑

两所大学中的智能车竞赛校内赛