Advertisement
vaibhav1906

Good Number

Dec 17th, 2021
1,460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. string fun(int n){
  5.    
  6.     queue<string>q;
  7.    
  8.     q.push("1");
  9.     q.push("2");
  10.    
  11.     while(n>1){
  12.         q.push(q.front()+"1");
  13.         q.push(q.front()+"2");
  14.        
  15.         q.pop();
  16.         n--;
  17.     }
  18.    
  19.    
  20.     return q.front();
  21. }
  22.  
  23. int main() {
  24.     //code
  25.  
  26.     int t;
  27.     cin>>t;
  28.    
  29.     while(t!=0){
  30.        
  31.         int n;
  32.         cin>>n;
  33.        
  34.         cout<<fun(n)<<endl;
  35.        
  36.        
  37.         t--;
  38.     }
  39.    
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement