#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
typedef unsigned long long ll;
struct _Node{
int depth;
ll val;
_Node(){
}
_Node(int _depth, ll _val)
{
depth = _depth; val = _val;
}
};
void bfs(int t)
{
queue<_Node> q;
q.push(_Node(0, 1));
while(!q.empty()){
_Node x = q.front(); q.pop();
//cout << x.val << endl;
if(x.depth == 19) return ;
if(x.val % t == 0)
{
printf("%I64u\n", x.val);
return ;
}
q.push(_Node(x.depth + 1, x.val * 10));
q.push(_Node(x.depth + 1, x.val * 10 + 1));
}
}
int main()
{
int t;
while(scanf("%d", &t) != EOF && t)
{
bfs(t);
}
return 0;
}
POJ-1426 (Find The Multiple) bfs
最新推荐文章于 2021-07-20 15:22:38 发布