POJ 1426 Find The Multiple

题目链接:https://vjudge.net/problem/POJ-1426

 1 #include<stdio.h>
 2 #include<queue>
 3 using namespace std;
 4 
 5 int n;
 6 
 7 bool bfs(){
 8 
 9     queue<long long> que;
10     long long a = 1;
11     que.push(a);
12 
13     while(!que.empty()){
14         long long b = que.front();
15         que.pop();
16 
17         if(b%n == 0){
18             printf("%lld\n",b);
19             return true;
20         }
21 
22         que.push(b*10);
23         que.push(b*10+1);
24     }
25 
26     return true;
27 }
28 
29 
30 int main(){
31 
32     while(scanf("%d",&n)){
33         if(!n) break;
34         bfs();
35     }
36 
37     return 0;
38 }

 

posted on 2019-10-13 19:14 SSummerZzz 阅读(...) 评论(...) 编辑 收藏

导航

统计