-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1426.cpp
More file actions
51 lines (44 loc) · 910 Bytes
/
Copy path1426.cpp
File metadata and controls
51 lines (44 loc) · 910 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
40
41
42
43
44
45
46
47
48
49
50
51
/*************************************************************************
> File Name: 1426.cpp
> Author: dulun
> Mail: dulun@xiyoulinux.org
> Created Time: 2016年01月25日 星期一 11时47分33秒
************************************************************************/
#include<iostream>
#include<stdio.h>
using namespace std;
struct queue{
long long x;
};
queue q[20000000];
void bfs(int n)
{
int front, rear;
q[front = rear = 0].x = 1;
rear++;
while(front < rear)
{
if(q[front].x % n != 0)
{
q[rear++].x = q[front].x * 10;
q[rear++].x = q[front].x * 10 + 1;
}
else
{
printf("%lld\n", q[front].x);
return;
}
front+=1;
}
}
int main()
{
while(1)
{
int n;
scanf("%d", &n);
if(0 == n) break;
bfs(n);
}
return 0;
}