Tranvick

Untitled

Feb 16th, 2012
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.49 KB | None | 0 0
  1. #pragma comment(linker, "/STACK:65777216")
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <cstdlib>
  5. #include <ctime>
  6. #include <cstdio>
  7. #include <algorithm>
  8. #include <cmath>
  9. #include <vector>
  10. #include <set>
  11. #include <stack>
  12. #include <map>
  13. #include <queue>
  14. #include <string>
  15. #include <memory.h>
  16. #include <iterator>
  17. #define y1 trololoy1
  18. #define y2 trololoy2
  19. #define mem(A,X) memset(A,X,sizeof(A))
  20. #define memo(A) memset(A,0,sizeof(A))
  21. #define forn(I,B) for (int I=1;I<=(B);I++)
  22. #define forg(H,V) for (int H=first[V];h;h=next[H])
  23. #define rep(I,B) for (int I=0;I<(B);I++)
  24. #define labs(X) (((X)>0)?(X):(-(X)))
  25. #define ropen(X) freopen(X,"r",stdin)
  26. #define wopen(X) freopen(X,"w",stdout)
  27. #define rwopen(X) freopen(X".in","r",stdin);freopen(X".out","w",stdout)
  28. #define pb push_back
  29. #define mp make_pair
  30. #define all(X) (X).begin(),(X).end()
  31. #define sqr(X) ((X)*(X))
  32.  
  33. using namespace std;
  34.  
  35. typedef pair <int,int> pii;
  36. typedef double ld;
  37. typedef long long ll;
  38. typedef pair <ll,ll> pll;
  39. typedef vector<int> vi;
  40. const int N=55;
  41. const int M=222;
  42. const int INF=111111111;
  43. const double eps=1e-9;
  44. const double pi=3.14159265358979;
  45.  
  46. int g[2][N],n,f[N],k,t;
  47. string q;
  48.  
  49. int main(){
  50.     f[0]=1;f[1]=2;f[2]=4;
  51.     g[0][1]=g[1][1]=1;
  52.     g[0][2]=g[1][2]=2;
  53.     for (int i=3;i<=50;i++){
  54.         g[0][i]=g[1][i-1]+g[1][i-2];
  55.         g[1][i]=g[1][i-1]+g[0][i-1];
  56.         f[i]=g[1][i]+g[0][i];
  57.     }
  58.     scanf("%d",&t);
  59.     while(t--){
  60.         scanf("%d%d",&n,&k);++k;
  61.         q="";
  62.         forn(i,n){
  63.             if (k>f[n-i]){
  64.                 k-=f[n-i];
  65.                 q+='1';
  66.             } else q+='0';
  67.         }
  68.         puts(q.c_str());
  69.     }
  70.     return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment