fork(1) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. string modulo(long long l, string curr){
  6. if(l < 0){
  7. return "";
  8.  
  9. }
  10. if(l == 0){
  11. return curr;
  12.  
  13. }
  14.  
  15. string temp = modulo(l >> 1, curr);
  16. if(temp.length() != 0){
  17. temp ="(" + temp + ")";
  18. }
  19. if(l & 1){
  20. temp += "A";
  21. }
  22. return temp;
  23. }
  24.  
  25. int main() {
  26. int t;
  27. cin>>t;
  28. while(t--){
  29. long long l;
  30. cin>>l;
  31. cout<<modulo(l, "")<<"\n";
  32.  
  33. }
  34. return 0;
  35. }
Success #stdin #stdout 0s 3480KB
stdin
5
1
2
5
6
13
stdout
A
(A)
((A))A
((A)A)
(((A)A))A