Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma comment(linker, "/STACK:65777216")
- #include <iostream>
- #include <iomanip>
- #include <cstdlib>
- #include <ctime>
- #include <cstdio>
- #include <algorithm>
- #include <cmath>
- #include <vector>
- #include <set>
- #include <stack>
- #include <map>
- #include <queue>
- #include <string>
- #include <memory.h>
- #include <iterator>
- #define y1 trololoy1
- #define y2 trololoy2
- #define mem(A,X) memset(A,X,sizeof(A))
- #define memo(A) memset(A,0,sizeof(A))
- #define forn(I,B) for (int I=1;I<=(B);I++)
- #define forg(H,V) for (int H=first[V];h;h=next[H])
- #define rep(I,B) for (int I=0;I<(B);I++)
- #define labs(X) (((X)>0)?(X):(-(X)))
- #define ropen(X) freopen(X,"r",stdin)
- #define wopen(X) freopen(X,"w",stdout)
- #define rwopen(X) freopen(X".in","r",stdin);freopen(X".out","w",stdout)
- #define pb push_back
- #define mp make_pair
- #define all(X) (X).begin(),(X).end()
- #define sqr(X) ((X)*(X))
- using namespace std;
- typedef pair <int,int> pii;
- typedef double ld;
- typedef long long ll;
- typedef pair <ll,ll> pll;
- typedef vector<int> vi;
- const int N=55;
- const int M=222;
- const int INF=111111111;
- const double eps=1e-9;
- const double pi=3.14159265358979;
- int g[2][N],n,f[N],k,t;
- string q;
- int main(){
- f[0]=1;f[1]=2;f[2]=4;
- g[0][1]=g[1][1]=1;
- g[0][2]=g[1][2]=2;
- for (int i=3;i<=50;i++){
- g[0][i]=g[1][i-1]+g[1][i-2];
- g[1][i]=g[1][i-1]+g[0][i-1];
- f[i]=g[1][i]+g[0][i];
- }
- scanf("%d",&t);
- while(t--){
- scanf("%d%d",&n,&k);++k;
- q="";
- forn(i,n){
- if (k>f[n-i]){
- k-=f[n-i];
- q+='1';
- } else q+='0';
- }
- puts(q.c_str());
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment