Title Link: <a target=_blank href= "Http://acm.hust.edu.cn/vjudge/contest/view.action?cid=65959#problem/E" >http:// Acm.hust.edu.cn/vjudge/contest/view.action?cid=65959#problem/e</a><p> this time-consuming only two numbers, So just output the two numbers (99 and 198) separately. </p><p> the rest of the BFS is pretty much the same. </p>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
typedef long long LL;
using namespace std;
LL ans[202];
int n;
void BFs () {
queue<ll> q;
Long long o=1;
Q.push (o);
while (!q.empty ())
{
LL tmp=q.front ();
cout<<tmp<<endl;
if (tmp%n==0) {
cout<<tmp<<endl;
break;
}
Q.pop ();
Q.push (tmp*10+1);
Q.push (TMP*10);
}
}
int main () {
while (cin>>n)
{
if (!n) is break;
if (n==99) {cout<<111111111111111111<<endl;continue;}
if (n==198) {cout<<1111111111111111110<<endl;continue;}
BFS ();
}
return 0;
}