1 #include <iostream> 2 #include <algorithm> 3 using namespace std; 4 5 int n; 6 bool ok; 7 8 void dfs(unsigned long long x, int y, int k){ 9 if(ok == true) return ; 10 if(x % y == 0){ 11 cout << x << endl; 12 ok = true; 13 return; 14 } 15 if(k == 19) return; 16 dfs(x*10, y, k+1); 17 dfs(x*10+1, y, k+1); 18 } 19 20 int main(){ 21 while(cin >> n){ 22 if( n == 0) 23 break; 24 ok = false; 25 dfs(1, n, 0); 26 } 27 return 0; 28 }