#include<iostream> #include<queue> //https://blog.csdn.net/lyy289065406/article/details/6647917 using namespace std; int m[530000]; int main(){ int i,len,n; while(scanf("%d",&n)==1&&n){ m[1] = 1; for(i=2;m[i-1]!=0;i++) m[i] = (m[i/2]*10+i%2)%n; i--; len = 0; while(i){ m[len++] = i%2; i /= 2; } while(len){ printf("%d",m[--len]); } printf("\n"); } return 0; }