Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "bits/stdc++.h"
- /*
- * Author: Matheus Monteiro
- */
- int getP(int x) {
- int p = 1;
- int ans = 0;
- while(2 * p - 1 <= x) {
- p *= 2;
- ++ans;
- }
- return ans;
- }
- void solve() {
- long long n;
- std::cin >> n;
- std::string ans;
- while(n > 0) {
- int p = getP(n);
- n -= ((1 << p) - 1);
- if(ans.empty()) {
- ans = std::string(p, 'a');
- } else {
- int l = ans.size() - 1;
- while(p > 0 and l > 0) {
- if(ans[l] == 'a') p--;
- if(p) l--;
- }
- ans.insert(ans.begin() + l, 'h');
- }
- }
- std::cout << "nunhehheh" << ans << '\n';
- }
- int32_t main() {
- int t = 1;
- std::cin >> t;
- for(int caso = 1; caso <= t; ++caso) {
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement