-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP1468.cpp
76 lines (76 loc) · 1.34 KB
/
P1468.cpp
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include<stdio.h>
int main()
{
int n, i, j, k, t, temp, x, p, q;
while(scanf("%d", &n) != EOF)
{
temp = 9;
int a[3000][30] = {0};
for(i=0; i<9; i++)
a[i][0] = i+1;
for(i = 2; i<= n; i++)
{
k = 0;
int b[3000][30], c[3000];
for(j = 0; j < temp; j++)
{
for(t = 0; t <= 9; t++) // ¸öλ¼ÓÉϵÄÊý(t)
{
x = 0;
for(p = 0; p < i - 1; p++)
x = (x * 10 + a[j][p]) % i;
x = (x * 10 + t) % i;
if(x == 0)
{
for(q = 0; q < i-1; q++)
b[k][q] = a[j][q];
b[k][q] = t;
k++;
while((t + i ) / 10 == 0)
{
t += i;
for(q = 0; q < i-1; q++)
b[k][q] = a[j][q];
b[k][q] = t;
k++;
}
break;
}
else
{
t = i - x;
if(t < 10)
{
for(q = 0; q < i-1; q++)
b[k][q] = a[j][q];
b[k][q] = t;
k++;
while((t + i ) / 10 == 0)
{
t += i;
for(q = 0; q < i-1; q++)
b[k][q] = a[j][q];
b[k][q] = t;
k++;
}
break;
}
}
}
}
for(j = 0; j < k; j++)
{
for(p = 0; p < i; p++)
a[j][p] = b[j][p];
}
temp = k;
}
for(i = 0; i < temp; i++)
{
for(j = 0; j < n; j++)
printf("%d", a[i][j]);
printf("\n");
}
}
return 0;
}