|
发表于 2021-3-20 15:30:02
|
显示全部楼层
- #include <stdio.h>
- #include <math.h>
- main()
- {
- long long int i, sum = 0;
- int j, k, flag = 1, array[7] = { 2, 3, 5, 7, 11, 13, 17 }, temp[10] = { 0 };
- char str[20], num[10];
- for (int a = 1; a < 10; a++)
- {
- temp[a] = 1;
- str[0] = a + '0';
- for (int b = 0; b < 10; b++)
- {
- if (temp[b])
- {
- continue;
- }
- temp[b] = 1;
- str[1] = b + '0';
- for (int c = 0; c < 10; c++)
- {
- if (temp[c])
- {
- continue;
- }
- temp[c] = 1;
- str[2] = c + '0';
- for (int d = 0; d < 10; d++)
- {
- if (temp[d])
- {
- continue;
- }
- temp[d] = 1;
- str[3] = d + '0';
- for (int e = 0; e < 10; e++)
- {
- if (temp[e])
- {
- continue;
- }
- temp[e] = 1;
- str[4] = e + '0';
- for (int f = 0; f < 10; f++)
- {
- if (temp[f])
- {
- continue;
- }
- temp[f] = 1;
- str[5] = f + '0';
- for (int g = 0; g < 10; g++)
- {
- if (temp[g])
- {
- continue;
- }
- temp[g] = 1;
- str[6] = g + '0';
- for (int h = 0; h < 10; h++)
- {
- if (temp[h])
- {
- continue;
- }
- temp[h] = 1;
- str[7] = h + '0';
- for (int m = 0; m < 10; m++)
- {
- if (temp[m])
- {
- continue;
- }
- temp[m] = 1;
- str[8] = m + '0';
- for (int n = 0; n < 10; n++)
- {
- if (temp[n])
- {
- continue;
- }
- temp[n] = 1;
- str[9] = n + '0';
- str[10] = '\0';
- for (j = 0; j < 7; j++)
- {
- num[0] = str[j + 1];
- num[1] = str[j + 2];
- num[2] = str[j + 3];
- num[3] = '\0';
- k = atoi(num);
- if (k % array[j])
- {
- flag = 0;
- break;
- }
- }
- if (flag)
- {
- i = atof(str);
- sum += i;
- printf("%lld\n", i);
- }
- flag = 1;
- temp[n] = 0;
-
- }
- temp[m] = 0;
- }
- temp[h] = 0;
- }
- temp[g] = 0;
- }
- temp[f] = 0;
- }
- temp[e] = 0;
- }
- temp[d] = 0;
- }
- temp[c] = 0;
- }
- temp[b] = 0;
- }
- temp[a] = 0;
-
- }
- printf("\n%lld\n", sum);
- }
复制代码
1406357289
1430952867
1460357289
4106357289
4130952867
4160357289
sum = 16695334890 |
|