POJ1426 BFS
2011-07-19 22:01
155 查看
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;
}
#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;
}
相关文章推荐
- poj1426之bfs打表解法
- POJ1426 倍数01 BFS(同余模定理)
- (POJ1426)Find The Multiple <BFS 大数模>
- poj1426(bfs dfs)
- POJ1426: Find The Multiple(bfs,同余定理)
- POJ1426 Find The Multiple(BFS)
- UVALive2701 UVA1189 POJ1426 ZOJ1530 Find The Multiple【BFS】
- POJ1426 BFS
- Poj1426 Find The Multiple (BFS)
- BFS POJ1426 Find The Multiple
- BFS 同余模定理 poj1426
- POJ1426 Find The Multiple(DFS||BFS||同余模定理)
- POJ1426 Find The Multiple —— BFS
- POJ1426:Find The Multiple(BFS)
- POJ1426:Find The Multiple(算是bfs水题吧,投机取巧过的)
- HDU_1254——推箱子,两次BFS
- BestCoder Round #53 (div.2) HDOJ5423 Rikka with Tree(bfs)
- POJ 1979 3669 DFS BFS
- NYOJ 592spiral grid(BFS)
- hdu2102 A计划(双层BFS)