posts - 100,  comments - 15,  trackbacks - 0
//菜鸟做法,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==0return t;
        que[rear
++]=t;
        t
+=1;
        
if(t%n==0return 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 阅读(455) 评论(0)  编辑 收藏 引用 所属分类: POJ

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理