Created
October 4, 2022 06:16
-
-
Save xmichael446/6b470a0963c9b31da3ac38055c9bff3a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
vector<long long> d(501, 0); | |
void rec(long long n, int k) { | |
for (int i = 1; i < 500; ++i) { | |
if (n % i == 0) { | |
if (d[i] == 0 || d[i] > n) { | |
d[i] = n; | |
} | |
} | |
} | |
if (k == 16) return; | |
rec(n * 10, k + 1); | |
rec(n * 10 + 9, k + 1); | |
} | |
int main() { | |
ifstream in("input.txt"); | |
ofstream out("output.txt"); | |
rec(9, 1); | |
out << fixed << setprecision(0); | |
int len; | |
in >> len; | |
for (int i = 0; i < len; ++i) { | |
int num; | |
in >> num; | |
out << d[num] << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment