Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Pratiyush Mishra
- #include <bits/stdc++.h>
- using namespace std;
- string uppercase(string s)
- {
- string ans = "";
- for (char c : s)
- {
- char d;
- if (c >= 'A' && c <= 'Z')
- d = c;
- else
- d = char(c - 'a' + 'A');
- ans += d;
- }
- return ans;
- }
- int countSetBits(char c)
- {
- int n = c;
- int count = 0;
- while (n) {
- count += n & 1;
- n >>= 1;
- }
- return count;
- }
- void decToOctal(int n)
- {
- int octalNum[100];
- int i = 0;
- while (n != 0) {
- octalNum[i] = n % 8;
- n = n / 8;
- i++;
- }
- string ans = "";
- for (int j = i - 1; j >= 0; j--)
- cout << octalNum[j];
- }
- void mainSolve()
- {
- string s;
- cin >> s;
- s = uppercase(s);
- int shift = 0;
- for (char c : s)
- shift += countSetBits(c);
- decToOctal(shift);
- string ans = "";
- for (char c : s)
- {
- int sft = (c - 'A' + shift) % 26;
- char d = char(sft + 'A');
- cout << d;
- }
- cout << endl;
- }
- int main()
- {
- int t = 1;
- while (t--)
- {
- mainSolve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement