题目链接:poj-1426
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#define maxn 205
using namespace std;
int n;
int work;
void dfs(int x, unsigned long long y, int z)
{
if (z == 19 || work)//超过20位还没找到
return;
if (y%x == 0)
{
work = 1;
cout << y << endl;
return;
}
dfs(x, y * 10, z + 1);//模拟0
dfs(x, y * 10 + 1, z + 1);//模拟1
}
int main()
{
while (cin >> n,n)
{
work = 0;
dfs(n, 1, 0);
}
}