-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy path9.2.cpp
More file actions
39 lines (35 loc) · 857 Bytes
/
9.2.cpp
File metadata and controls
39 lines (35 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* 题目名称:Find The Multiple
* 题目来源:POJ 1426
* 题目链接:http://poj.org/problem?id=1426
* 代码作者:杨泽邦(炉灰)
*/
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
void BFS(int n) {
queue<long long> myQueue;
myQueue.push(1); //压入初始状态
while (!myQueue.empty()) {
long long current = myQueue.front();
myQueue.pop();
if (current % n == 0) { //查找成功
printf("%lld\n", current);
return ;
}
myQueue.push(current * 10);
myQueue.push(current * 10 + 1);
}
return ;
}
int main() {
int n;
while (scanf("%d", &n) != EOF) {
if (n == 0) {
break;
}
BFS(n);
}
return 0;
}