hdoj1287_破譯密碼

來源:互聯網
上載者:User
破譯密碼 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3249    Accepted Submission(s): 1466


Problem Description 有個叫“豬頭幫”的國家,採用一種簡單的文法加密,他們所用的語言裡面只有大寫字母,沒有其他任何字元;現在還知道他們加密的方法是:只用一個大寫字母和原文進行異或運算產生密文。請你幫忙解開。  
Input 有若干組,每組輸入有2行,第一行整數N表示有N個密文,接著一行有N個整數分別表示N個密文。  
Output 輸出僅有大寫字母組成的原文。
 
Sample Input
 30 17 6 9 8 3 0 1 6 7 4 5 10 11 8 9 14 15 12 13 18 19 16 17 22 23 20 21 26 27 24   

Sample Output
 SDKJABCDEFGHIJKLMNOPQRSTUVWXYZ a ^ b = c a ^ c = b b ^ c = a 
#include <iostream>//位元運算#include <cstdio>#include <cstring>using namespace std;char dic[27]={"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};int arr[1000000];int main(){int t;while (scanf("%d", &t) != EOF){for (int i = 0; i < t; i++)scanf("%d", &arr[i]);for (int i = 0; i < 26; i++){int j;for (j = 0; j < t; j++){char  ch = arr[j] ^ dic[i];if (ch < 'A' || ch > 'Z')break;}if (j == t){for (int j = 0; j < t; j++)printf("%c", arr[j] ^ dic[i]);printf("\n");break;}}}return 0;}



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.