aboutsummaryrefslogtreecommitdiff
path: root/PolyCarpAndDividend/main.cpp
diff options
context:
space:
mode:
authoromagdy7 <omar.professional8777@gmail.com>2022-11-05 01:41:11 +0200
committeromagdy7 <omar.professional8777@gmail.com>2022-11-05 01:41:11 +0200
commit7f856c7ff080b8d455b9ed16c2e57dd862c3879d (patch)
treec2baf90f98c91567358003d6b97a4afed7fa9b42 /PolyCarpAndDividend/main.cpp
parentc52b36c6a37fdb1d1de146d3939cb42e2c691f44 (diff)
downloadcompetitive-programming-7f856c7ff080b8d455b9ed16c2e57dd862c3879d.tar.xz
competitive-programming-7f856c7ff080b8d455b9ed16c2e57dd862c3879d.zip
moved some file
Diffstat (limited to 'PolyCarpAndDividend/main.cpp')
-rw-r--r--PolyCarpAndDividend/main.cpp49
1 files changed, 0 insertions, 49 deletions
diff --git a/PolyCarpAndDividend/main.cpp b/PolyCarpAndDividend/main.cpp
deleted file mode 100644
index 81e6a92..0000000
--- a/PolyCarpAndDividend/main.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-#include <bits/stdc++.h>
-
-using namespace std;
-
-const int N = 1234567;
-
-int a[12], p[N], e[N];
-bool vis[N];
-
-void print(int x) {
- if (x == -1) return;
- print(p[x]);
- printf("%d", e[x]);
-}
-
-int main() {
- int n, m;
- scanf("%d", &n);
- for (int i = 0; i < n; i++) {
- scanf("%d", a + i);
- }
- sort(a, a + n);
- scanf("%d", &m);
- int cnt = 0;
- queue < pair <int, int> > q;
- q.push(make_pair(-1, 0));
- while (!q.empty()) {
- int u = q.front().first;
- int x = q.front().second;
- q.pop();
- for (int i = 0; i < n; i++) {
- int v = (x * 10 + a[i]) % m;
- if (u == -1 && a[i] == 0) continue;
- if (!vis[v]) {
- vis[v] = true;
- q.push(make_pair(cnt, v));
- e[cnt] = a[i];
- p[cnt++] = u;
- }
- if (v == 0) {
- print(cnt - 1);
- return 0;
- }
- }
- }
- puts("-1");
- return 0;
-}
-