fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. #define endl "\n"
  4. #define F first
  5. #define S second
  6. #define loop(a,n) for(int i=a; i<=n ; i++)
  7. #define TIME (1.0 * clock() / CLOCKS_PER_SEC)
  8. #define NAME "CH"
  9. using namespace std;
  10. string s,n,res;
  11. int k;
  12. void nhap(){
  13. cin >> n;
  14. cin.ignore();
  15. getline(cin, s);
  16. }
  17. int op(string num, int x){
  18. int res = 0;
  19. for(int i=0;i<num.size();++i) {
  20. res = (res * 10 + num[i] - '0') % x;
  21. }
  22. return res;
  23. }
  24. string to_upper(string s){
  25. for(int i = 0; i < s.size(); i++){
  26. if(s[i] >= 'a' && s[i] <= 'z'){
  27. s[i] -= 32;
  28. }
  29. }
  30. return s;
  31. }
  32. string decode(string s, int k){
  33. string res;
  34. for(int i = 0; i < s.size(); ++i) {
  35. if(s[i] == ' ') {
  36. res += ' ';
  37. } else {
  38. char x = s[i] - k;
  39. if (x < 'A') x += 26;
  40. res += x;
  41. }
  42. }
  43. return res;
  44. }
  45.  
  46. void solve(){
  47. k = op(n, 26);
  48. s = to_upper(s);
  49. res = decode(s,k);
  50. }
  51. void xuat(){
  52. cout<<res;
  53. }
  54. int main(){
  55. ios_base::sync_with_stdio(0);
  56. cin.tie(0);cout.tie(0);
  57. freopen(NAME".INP","r",stdin);
  58. freopen(NAME".OUT","w",stdout);
  59. nhap();
  60. solve();
  61. xuat();
  62. return 0;
  63. }
Success #stdin #stdout 0s 5328KB
stdin
Standard input is empty
stdout
Standard output is empty