您的位置:首页 > 其它

POJ1426 BFS

2011-07-19 22:01 176 查看
BFS水过去,但是还得用到__int 否则就纠结了。

#include<iostream>

using namespace std;
const int N=200,M=100;
int n;
__int64 que[9999999];
void bfs()
{
int head=1,tail=1;
que[tail++]=1;
while(head<tail)
{
__int64 now=que[head++];
if(now%n==0)
{
printf("%I64d\n",now);
return;
}
que[tail++]=now*10;
que[tail++]=now*10+1;
}
}
int main()
{
//freopen("C:\\Users\\wuyanyisb\\Desktop\\1.txt","r",stdin);
while(scanf("%d\n",&n),n!=0)
{
bfs();
}
system("pause");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: