//菜鳥做法,BFS,n==99,內存空間無敵的大...
#include<iostream>
using namespace std;
//usig64_18,446,744,073,709,551,615_20wei
__int64 que[800000];
__int64 n;
__int64 t;
__int64 bfs()


{
int front=0,rear=0;
que[rear++]=1;
while(front<rear)

{
t=que[front++];
t*=10;
if(t%n==0) return t;
que[rear++]=t;
t+=1;
if(t%n==0) return t;
que[rear++]=t;
}
}
int main()


{
while(scanf("%I64d",&n)!=EOF && n)

{
printf("%I64d\n",bfs());
}
return 0;
}
posted on 2009-07-23 13:57
wyiu 閱讀(469)
評論(0) 編輯 收藏 引用 所屬分類:
POJ