pratiyush7

Untitled

Dec 2nd, 2021
627
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Pratiyush Mishra
  2.  
  3. #include <bits/stdc++.h>
  4. #define ull unsigned long long int
  5. #define ll long long int
  6. #define LL_MAX 9223372036854775807
  7. #define pb push_back
  8. #define pf push_front
  9. #define mp make_pair
  10. #define popb pop_back
  11. #define vl vector<ll>
  12. #define pl pair<ll,ll>
  13. #define bs(v, x) binary_search(v.begin(), v.end(), x)
  14. #define mem1(a) memset(a, -1, sizeof(a))
  15. #define popf pop_front
  16. #define p0(x) cout << x << " "
  17. #define p1(x) cout << x << '\n'
  18. #define p2(x, y) cout << x << " " << y << '\n'
  19. #define p3(x, y, z) cout << x << " " << y << " " << z << '\n'
  20. #define printv(v)                   \
  21.   for (ll i = 0; i < v.size(); ++i) \
  22.     cout << v[i] << " ";            \
  23.   cout << '\n'
  24. #define pr1(x) cout << fixed << setprecision(15) << x << '\n'
  25. #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update>
  26. // ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
  27. // s.find_by_order(i)  itertor to ith element (0 indexed)
  28. #define mod 1000000007
  29. #define mod1 998244353
  30. #define fio                         \
  31.   ios_base::sync_with_stdio(false); \
  32.   cin.tie(NULL)
  33. #define get(n) \
  34.   ll n;        \
  35.   cin >> n
  36. #define getvec(v, n)         \
  37.   vector<ll> v(n);           \
  38.   for (ll i = 0; i < n; i++) \
  39.     cin >> v[i];
  40. #define getstr(s) \
  41.   string s;       \
  42.   cin >> s
  43. #define all(x) x.begin(), x.end()
  44. #define countBits(x) __builtin_popcount(x)
  45. using namespace std;
  46.  
  47. string uppercase(string s)
  48. {
  49.   string ans = "";
  50.   for (char c : s)
  51.   {
  52.     char d;
  53.     if (c >= 'A' && c <= 'Z')
  54.       d = c;
  55.     else
  56.       d = char(c  - 'a' + 'A');
  57.     ans += d;
  58.   }
  59.   return ans;
  60. }
  61.  
  62. int countSetBits(char c)
  63. {
  64.   int n = c;
  65.   int count = 0;
  66.   while (n) {
  67.     count += n & 1;
  68.     n >>= 1;
  69.   }
  70.   return count;
  71. }
  72.  
  73. void decToOctal(int n)
  74. {
  75.   int octalNum[100];
  76.   int i = 0;
  77.   while (n != 0) {
  78.     octalNum[i] = n % 8;
  79.     n = n / 8;
  80.     i++;
  81.   }
  82.   string ans = "";
  83.   for (int j = i - 1; j >= 0; j--)
  84.     cout << octalNum[j];
  85. }
  86.  
  87. void mainSolve()
  88. {
  89.   string s;
  90.   cin >> s;
  91.   s = uppercase(s);
  92.   int shift = 0;
  93.   for (char c : s)
  94.     shift += countSetBits(c);
  95.   decToOctal(shift);
  96.   string ans = "";
  97.   for (char c : s)
  98.   {
  99.     int sft = (c - 'A' + shift) % 26;
  100.     char d = char(sft + 'A');
  101.     cout << d;
  102.   }
  103.   cout << endl;
  104. }
  105.  
  106. int main()
  107. {
  108.   fio;
  109. #ifndef ONLINE_JUDGE
  110.   freopen("input.txt", "r", stdin);
  111.   freopen("output.txt", "w", stdout);
  112. #endif
  113.   //get(t);
  114.   ll t = 1;
  115.   while (t--)
  116.   {
  117.     mainSolve();
  118.   }
  119.   return 0;
  120. }
  121.  
RAW Paste Data