[Cpp] Description: Dangerous, 2.856 s. It indicates the first few digits can be divisible. n indicates that it starts from the nth digit, and m indicates that it ends at the m digit, if a number exists in this period and can be divided from n to m, it is output. If there are multiple, select the smallest output. If not, output-1 # include <cstdio> # include <cstdlib> # include <cstring> int n, m, flag, sum; char str [35]; int cal (int cur) {int c = 0; for (int I = 0; I <cur; I ++) c = (c * 10 + str [I]-'0') % cur; return c;} void dfs (int cur) {if (flag) return; if (cur = m) {flag = 1; printf ("% s \ n ", str); return;} for (int I = 0; I <10; ++ I) {str [cur] = '0' + I; if (cur <n-1 |! Cal (cur + 1) dfs (cur + 1); if (flag) return ;}} int main () {// freopen ("a.txt", "r ", stdin); int t, c = 1; scanf ("% d", & t); while (c <= t) {scanf ("% d ", & n, & m); printf ("Case % d:", c ++); flag = sum = 0; if (n <m) for (int I = 1; I <10; ++ I) {str [0] = I + '0'; dfs (1); if (flag) break;} if (! Flag) printf ("-1 \ n");} return 0 ;}