继续简单题 bfs
搜索十进制数里面只有0和1的能够整除输入数的数字
long long型
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <cctype>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <map>
#include <queue>
#include <list>
#include <iomanip>
using namespace std;
///
///
#define INF 0xffffff7
#define maxn 50
#define max(a,b)(a>b?a:b)
///
long long tmp, ans;
queue<long long> stk;
int n;
void bfs()
{
int i, j;
while(!stk.empty())
stk.pop();
tmp = 1;
stk.push(tmp);
while(!stk.empty())
{
tmp = stk.front();
stk.pop();
if(tmp % n == 0)
{
ans = tmp;
break;
}
stk.push(tmp * 10);
stk.push(tmp * 10 + 1);
}
}
int main()
{
///
int i, j, k;
while (1)
{
cin >> n;
if(n == 0)
break;
bfs();
cout << ans << endl;
}
///
return 0;
}