Created
May 27, 2015 14:37
-
-
Save zsrinivas/97fbfd1b8ef11c02bb4b to your computer and use it in GitHub Desktop.
spoj ➡ classical ➡ dcrypt ➡ Decrypt the message!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
#ifdef __mr__ | |
#include "prettyprint.hpp" | |
#endif | |
#define endl ('\n') | |
#define i32inf (0x7fffffff) | |
#define i32_inf (-0x7fffffff-1) | |
#define i64inf (0x7fffffffffffffff) | |
#define i64_inf (-0x7fffffffffffffff-1) | |
#define ui32inf (0xffffffffu) | |
#define ui64inf (0xffffffffffffffffu) | |
#define bitcounti32 __builtin_popcount | |
#define bitcounti64 __builtin_popcountll | |
using namespace std; | |
int testcases; | |
int main() { | |
ios::sync_with_stdio(0);cin.tie(0); | |
cin >> testcases; | |
for (int test = 1; test <= testcases; ++test) { | |
int key; | |
string encrypted, decrypted; | |
cin >> key >> encrypted; | |
for (char c: encrypted) { | |
if (c == '.') | |
decrypted += ' '; | |
else | |
decrypted += | |
((c - (isupper(c)?'A':'a')) + key) % 26 + | |
((((bool)isupper(c)) == (key <= 25))?'A':'a'); | |
} | |
cout << decrypted << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment